fix(postgres): correct package and secret audit coverage
This commit is contained in:
1 parent
f7caf2c40e
commit
36cd4b09b4
6 files changed
+111
-77
No files matched your search
@@ -36,26 +36,11 @@ func (q *Queries) GetHarnessSecret(ctx context.Context, arg GetHarnessSecretPara
|
||||
return i, err
|
||||
}
|
||||
|
||||
const harnessSecretExists = `-- name: HarnessSecretExists :one
|
||||
SELECT EXISTS (SELECT 1 FROM harness_secrets WHERE org = $1 AND service = $2)
|
||||
`
|
||||
|
||||
type HarnessSecretExistsParams struct {
|
||||
Org string
|
||||
Service string
|
||||
}
|
||||
|
||||
func (q *Queries) HarnessSecretExists(ctx context.Context, arg HarnessSecretExistsParams) (bool, error) {
|
||||
row := q.db.QueryRow(ctx, harnessSecretExists, arg.Org, arg.Service)
|
||||
var exists bool
|
||||
err := row.Scan(&exists)
|
||||
return exists, err
|
||||
}
|
||||
|
||||
const putHarnessSecret = `-- name: PutHarnessSecret :exec
|
||||
const putHarnessSecret = `-- name: PutHarnessSecret :one
|
||||
INSERT INTO harness_secrets (org, service, secret_enc, updated_at)
|
||||
VALUES ($1, $2, $3, now())
|
||||
ON CONFLICT (org, service) DO UPDATE SET secret_enc = EXCLUDED.secret_enc, updated_at = now()
|
||||
RETURNING (xmax = 0) AS inserted
|
||||
`
|
||||
|
||||
type PutHarnessSecretParams struct {
|
||||
@@ -64,7 +49,11 @@ type PutHarnessSecretParams struct {
|
||||
SecretEnc string
|
||||
}
|
||||
|
||||
func (q *Queries) PutHarnessSecret(ctx context.Context, arg PutHarnessSecretParams) error {
|
||||
_, err := q.db.Exec(ctx, putHarnessSecret, arg.Org, arg.Service, arg.SecretEnc)
|
||||
return err
|
||||
// inserted is true only when this statement created the row: xmax is zero for
|
||||
// a fresh insert and nonzero for the upsert's update side.
|
||||
func (q *Queries) PutHarnessSecret(ctx context.Context, arg PutHarnessSecretParams) (bool, error) {
|
||||
row := q.db.QueryRow(ctx, putHarnessSecret, arg.Org, arg.Service, arg.SecretEnc)
|
||||
var inserted bool
|
||||
err := row.Scan(&inserted)
|
||||
return inserted, err
|
||||
}
|
||||
Reference in new issue
Block a user