feat(staterpc): one run credential per task, kept in the State Store, authorizes its store calls and its push
This commit is contained in:
1 parent
ad13393e6b
commit
319e8f4945
18 files changed
+1809
-1470
No files matched your search
@@ -0,0 +1,60 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.31.1
|
||||
// source: run_credentials.sql
|
||||
|
||||
package postgresdb
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
)
|
||||
|
||||
const deleteExpiredRunCredentials = `-- name: DeleteExpiredRunCredentials :exec
|
||||
DELETE FROM run_credentials WHERE expires_at <= $1
|
||||
`
|
||||
|
||||
func (q *Queries) DeleteExpiredRunCredentials(ctx context.Context, expiresAt time.Time) error {
|
||||
_, err := q.db.Exec(ctx, deleteExpiredRunCredentials, expiresAt)
|
||||
return err
|
||||
}
|
||||
|
||||
const deleteRunCredential = `-- name: DeleteRunCredential :exec
|
||||
DELETE FROM run_credentials WHERE digest = $1
|
||||
`
|
||||
|
||||
func (q *Queries) DeleteRunCredential(ctx context.Context, digest []byte) error {
|
||||
_, err := q.db.Exec(ctx, deleteRunCredential, digest)
|
||||
return err
|
||||
}
|
||||
|
||||
const insertRunCredential = `-- name: InsertRunCredential :exec
|
||||
INSERT INTO run_credentials (digest, task_id, expires_at) VALUES ($1, $2, $3)
|
||||
`
|
||||
|
||||
type InsertRunCredentialParams struct {
|
||||
Digest []byte
|
||||
TaskID int64
|
||||
ExpiresAt time.Time
|
||||
}
|
||||
|
||||
func (q *Queries) InsertRunCredential(ctx context.Context, arg InsertRunCredentialParams) error {
|
||||
_, err := q.db.Exec(ctx, insertRunCredential, arg.Digest, arg.TaskID, arg.ExpiresAt)
|
||||
return err
|
||||
}
|
||||
|
||||
const runCredentialTask = `-- name: RunCredentialTask :one
|
||||
SELECT task_id FROM run_credentials WHERE digest = $1 AND expires_at > $2
|
||||
`
|
||||
|
||||
type RunCredentialTaskParams struct {
|
||||
Digest []byte
|
||||
ExpiresAt time.Time
|
||||
}
|
||||
|
||||
func (q *Queries) RunCredentialTask(ctx context.Context, arg RunCredentialTaskParams) (int64, error) {
|
||||
row := q.db.QueryRow(ctx, runCredentialTask, arg.Digest, arg.ExpiresAt)
|
||||
var task_id int64
|
||||
err := row.Scan(&task_id)
|
||||
return task_id, err
|
||||
}
|
||||
Reference in new issue
Block a user