You've already forked agentic-coding-workflow
79 lines
2.1 KiB
Go
79 lines
2.1 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.31.1
|
|
// source: credentials.sql
|
|
|
|
package workspacesqlc
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/jackc/pgx/v5/pgtype"
|
|
)
|
|
|
|
const getCredentialByWorkspace = `-- name: GetCredentialByWorkspace :one
|
|
SELECT id, workspace_id, kind, username, encrypted_secret, fingerprint, created_at, updated_at, key_version FROM git_credentials WHERE workspace_id = $1
|
|
`
|
|
|
|
func (q *Queries) GetCredentialByWorkspace(ctx context.Context, workspaceID pgtype.UUID) (GitCredential, error) {
|
|
row := q.db.QueryRow(ctx, getCredentialByWorkspace, workspaceID)
|
|
var i GitCredential
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.WorkspaceID,
|
|
&i.Kind,
|
|
&i.Username,
|
|
&i.EncryptedSecret,
|
|
&i.Fingerprint,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.KeyVersion,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const upsertCredential = `-- name: UpsertCredential :one
|
|
INSERT INTO git_credentials (id, workspace_id, kind, username, encrypted_secret, fingerprint)
|
|
VALUES ($1,$2,$3,$4,$5,$6)
|
|
ON CONFLICT (workspace_id) DO UPDATE
|
|
SET kind = EXCLUDED.kind,
|
|
username = EXCLUDED.username,
|
|
encrypted_secret = EXCLUDED.encrypted_secret,
|
|
fingerprint = EXCLUDED.fingerprint,
|
|
updated_at = now()
|
|
RETURNING id, workspace_id, kind, username, encrypted_secret, fingerprint, created_at, updated_at, key_version
|
|
`
|
|
|
|
type UpsertCredentialParams struct {
|
|
ID pgtype.UUID `json:"id"`
|
|
WorkspaceID pgtype.UUID `json:"workspace_id"`
|
|
Kind string `json:"kind"`
|
|
Username *string `json:"username"`
|
|
EncryptedSecret []byte `json:"encrypted_secret"`
|
|
Fingerprint *string `json:"fingerprint"`
|
|
}
|
|
|
|
func (q *Queries) UpsertCredential(ctx context.Context, arg UpsertCredentialParams) (GitCredential, error) {
|
|
row := q.db.QueryRow(ctx, upsertCredential,
|
|
arg.ID,
|
|
arg.WorkspaceID,
|
|
arg.Kind,
|
|
arg.Username,
|
|
arg.EncryptedSecret,
|
|
arg.Fingerprint,
|
|
)
|
|
var i GitCredential
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.WorkspaceID,
|
|
&i.Kind,
|
|
&i.Username,
|
|
&i.EncryptedSecret,
|
|
&i.Fingerprint,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.KeyVersion,
|
|
)
|
|
return i, err
|
|
}
|