diff --git a/.gitea/workflows/secrets.yml b/.gitea/workflows/secrets.yml index 149b204..1d79698 100644 --- a/.gitea/workflows/secrets.yml +++ b/.gitea/workflows/secrets.yml @@ -228,7 +228,7 @@ jobs: build-linux: name: Build (x86_64-unknown-linux-musl) needs: [version, probe-runners, check] - if: needs.probe-runners.outputs.has_linux == 'true' + if: always() && needs.check.result == 'success' && needs.probe-runners.outputs.has_linux == 'true' runs-on: debian timeout-minutes: 1 steps: @@ -277,7 +277,7 @@ jobs: build-macos: name: Build (aarch64-apple-darwin) needs: [version, probe-runners, check] - if: needs.probe-runners.outputs.has_macos == 'true' + if: always() && needs.check.result == 'success' && needs.probe-runners.outputs.has_macos == 'true' runs-on: darwin-arm64 timeout-minutes: 1 steps: @@ -324,7 +324,7 @@ jobs: build-windows: name: Build (x86_64-pc-windows-msvc) needs: [version, probe-runners, check] - if: needs.probe-runners.outputs.has_windows == 'true' + if: always() && needs.check.result == 'success' && needs.probe-runners.outputs.has_windows == 'true' runs-on: windows timeout-minutes: 1 steps: diff --git a/src/commands/update.rs b/src/commands/update.rs index e55d8f1..94c02d6 100644 --- a/src/commands/update.rs +++ b/src/commands/update.rs @@ -1,9 +1,18 @@ use anyhow::Result; use serde_json::{Map, Value}; -use sqlx::PgPool; +use sqlx::{FromRow, PgPool}; +use uuid::Uuid; use super::add::parse_kv; +#[derive(FromRow)] +struct UpdateRow { + id: Uuid, + tags: Vec, + metadata: Value, + encrypted: Value, +} + pub struct UpdateArgs<'a> { pub namespace: &'a str, pub kind: &'a str, @@ -17,16 +26,16 @@ pub struct UpdateArgs<'a> { } pub async fn run(pool: &PgPool, args: UpdateArgs<'_>) -> Result<()> { - let row = sqlx::query!( + let row: Option = sqlx::query_as( r#" SELECT id, tags, metadata, encrypted FROM secrets WHERE namespace = $1 AND kind = $2 AND name = $3 "#, - args.namespace, - args.kind, - args.name, ) + .bind(args.namespace) + .bind(args.kind) + .bind(args.name) .fetch_optional(pool) .await?; @@ -76,17 +85,17 @@ pub async fn run(pool: &PgPool, args: UpdateArgs<'_>) -> Result<()> { } let encrypted = Value::Object(enc_map); - sqlx::query!( + sqlx::query( r#" UPDATE secrets SET tags = $1, metadata = $2, encrypted = $3, updated_at = NOW() WHERE id = $4 "#, - &tags, - metadata, - encrypted, - row.id, ) + .bind(&tags) + .bind(metadata) + .bind(encrypted) + .bind(row.id) .execute(pool) .await?;