diff --git a/rust/src/out b/rust/src/out deleted file mode 100644 index f0df2d4..0000000 --- a/rust/src/out +++ /dev/null @@ -1,138 +0,0 @@ -pub struct InventoryItem { - pub id: Uuid, - pub name: String, - pub description: Option, - pub weight: i64, - pub category: Category, - pub product: Option, -} - -struct DbInventoryItemRow { - pub id: String, - pub name: String, - pub description: Option, - pub weight: i64, - pub category_id: String, - pub category_name: String, - pub category_description: Option, - pub product_id: Option, - pub product_name: Option, - pub product_description: Option, - pub product_comment: Option, -} - -impl TryFrom for InventoryItem { - type Error = Error; - - fn try_from(row: DbInventoryItemRow) -> Result { - Ok(InventoryItem { - id: Uuid::try_parse(&row.id)?, - name: row.name, - description: row.description, - weight: row.weight, - category: Category { - id: Uuid::try_parse(&row.category_id)?, - name: row.category_name, - description: row.category_description, - items: None, - }, - product: row - .product_id - .map(|id| -> Result { - Ok(Product { - id: Uuid::try_parse(&id)?, - name: row.product_name.unwrap(), - description: row.product_description, - comment: row.product_comment, - }) - }) - .transpose()?, - }) - } -} - -impl InventoryItem { - pub async fn find(pool: &sqlx::Pool, id: Uuid) -> Result, Error> { - let id_param = id.to_string(); - - sqlx::query_as!( - DbInventoryItemRow, - "SELECT - item.id AS id, - item.name AS name, - item.description AS description, - weight, - category.id AS category_id, - category.name AS category_name, - category.description AS category_description, - product.id AS product_id, - product.name AS product_name, - product.description AS product_description, - product.comment AS product_comment - FROM inventory_items AS item - INNER JOIN inventory_items_categories as category - ON item.category_id = category.id - LEFT JOIN inventory_products AS product - ON item.product_id = product.id - WHERE item.id = ?", - id_param, - ) - .fetch_optional(pool) - .await? - .map(|row| row.try_into()) - .transpose() - } - - pub async fn name_exists(pool: &sqlx::Pool, name: &str) -> Result { - Ok(sqlx::query!( - "SELECT id - FROM inventory_items - WHERE name = ?", - name, - ) - .fetch_optional(pool) - .await? - .map(|_row| ()) - .is_some()) - } - - pub async fn delete(pool: &sqlx::Pool, id: Uuid) -> Result { - let id_param = id.to_string(); - let results = sqlx::query!( - "DELETE FROM inventory_items - WHERE id = ?", - id_param - ) - .execute(pool) - .await?; - - Ok(results.rows_affected() != 0) - } - - pub async fn save( - pool: &sqlx::Pool, - name: &str, - category_id: Uuid, - weight: u32, - ) -> Result { - let id = Uuid::new_v4(); - let id_param = id.to_string(); - let category_id_param = category_id.to_string(); - - sqlx::query!( - "INSERT INTO inventory_items - (id, name, description, weight, category_id) - VALUES - (?, ?, ?, ?, ?)", - id_param, - name, - "", - weight, - category_id_param - ) - .execute(pool) - .await?; - - Ok(id) - } -} diff --git a/rust/test/tests/tmp b/rust/test/tests/tmp deleted file mode 100644 index ca47adf..0000000 --- a/rust/test/tests/tmp +++ /dev/null @@ -1,60 +0,0 @@ - - - // // Find element from element. - // let elem_text = elem_form.find(By::Id("searchInput")).await?; - - // // Type in the search terms. - // elem_text.send_keys("selenium").await?; - - // // Click the search button. - // let elem_button = elem_form.find(By::Css("button[type='submit']")).await?; - // elem_button.click().await?; - - // // Look for header to implicitly wait for the page to load. - // driver.find(By::ClassName("firstHeading")).await?; - // assert_eq!(driver.title().await?, "Selenium - Wikipedia"); - - // Always explicitly close the browser. - - // # browser.open('/') - - // # browser.should(have.title('Packager')) - // # browser.should(have.url(url("/"))) - // # browser.element(by.id('header')).should(have.text("Packager")) - // # browser.element(by.id('header')).element(by.id("header-link-inventory")).click() - // # browser.should(have.url(url("/inventory/"))) - // # browser.element(by.id('header')).element(by.id("header-link-trips")).click() - // # browser.should(have.url(url("/trips/"))) - // # browser.element(by.id('header')).element(by.id("home")).click() - // # browser.should(have.url(url("/"))) - - // browser.open('/inventory/') - - // head = browser.element('#category-list').element("thead") - // head.all("th").first.should(have.text("Name")) - // head.all("th").second.should(have.text("Weight")) - - // body = browser.element('#category-list').element("tbody") - // body.all("tr").should(have.size(1)) - // row = body.all("tr")[-1] - // row.all("td").first.should(have.text("Sum")) - // row.all("td").second.should(have.text("0")) - - // value = randname() - - // new_category = browser.element('#new-category') - // new_category.element('#new-category-name').type(value) - // new_category.submit() - - // body = browser.element('#category-list').element("tbody") - // body.all("tr").should(have.size(2)) - // row = body.all("tr").first - // row.all("td").first.should(have.text(value)) - // row.all("td").second.should(have.text("0")) - - // row = body.all("tr")[-1].all("td").second.should(have.text("0")) - - // browser.quit() - // print("Success") - - // Ok(()) diff --git a/rust/update-k8s.sh b/rust/update-k8s.sh new file mode 100755 index 0000000..9eafa09 --- /dev/null +++ b/rust/update-k8s.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash + +set -o nounset +set -o pipefail +set -o errexit + +id=$(pwgen -s 25 1) +url=registry.hkoerber.de/packager:$id + +echo "NEW URL: " $url + +./build-container.sh + +docker tag packager:latest $url +docker push $url + +pushd ~/projects/mycloud/ + +./kubectl.sh set image \ + deployment/$(./kubectl.sh get deployment --output=jsonpath={.items..metadata.name} -l app=packager) \ + packager=$url \ No newline at end of file