mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat: implement runtime configuration package with multi-org support (#14624)
runtime configuration package --------- Signed-off-by: Danny Kopping <danny@coder.com> Co-authored-by: Danny Kopping <danny@coder.com>
This commit is contained in:
co-authored by
Danny Kopping
parent
9da646704b
commit
cb9d40fb8a
@@ -6703,6 +6703,16 @@ func (q *sqlQuerier) UpdateCustomRole(ctx context.Context, arg UpdateCustomRoleP
|
||||
return i, err
|
||||
}
|
||||
|
||||
const deleteRuntimeConfig = `-- name: DeleteRuntimeConfig :exec
|
||||
DELETE FROM site_configs
|
||||
WHERE site_configs.key = $1
|
||||
`
|
||||
|
||||
func (q *sqlQuerier) DeleteRuntimeConfig(ctx context.Context, key string) error {
|
||||
_, err := q.db.ExecContext(ctx, deleteRuntimeConfig, key)
|
||||
return err
|
||||
}
|
||||
|
||||
const getAnnouncementBanners = `-- name: GetAnnouncementBanners :one
|
||||
SELECT value FROM site_configs WHERE key = 'announcement_banners'
|
||||
`
|
||||
@@ -6844,6 +6854,17 @@ func (q *sqlQuerier) GetOAuthSigningKey(ctx context.Context) (string, error) {
|
||||
return value, err
|
||||
}
|
||||
|
||||
const getRuntimeConfig = `-- name: GetRuntimeConfig :one
|
||||
SELECT value FROM site_configs WHERE site_configs.key = $1
|
||||
`
|
||||
|
||||
func (q *sqlQuerier) GetRuntimeConfig(ctx context.Context, key string) (string, error) {
|
||||
row := q.db.QueryRowContext(ctx, getRuntimeConfig, key)
|
||||
var value string
|
||||
err := row.Scan(&value)
|
||||
return value, err
|
||||
}
|
||||
|
||||
const insertDERPMeshKey = `-- name: InsertDERPMeshKey :exec
|
||||
INSERT INTO site_configs (key, value) VALUES ('derp_mesh_key', $1)
|
||||
`
|
||||
@@ -6975,6 +6996,21 @@ func (q *sqlQuerier) UpsertOAuthSigningKey(ctx context.Context, value string) er
|
||||
return err
|
||||
}
|
||||
|
||||
const upsertRuntimeConfig = `-- name: UpsertRuntimeConfig :exec
|
||||
INSERT INTO site_configs (key, value) VALUES ($1, $2)
|
||||
ON CONFLICT (key) DO UPDATE SET value = $2 WHERE site_configs.key = $1
|
||||
`
|
||||
|
||||
type UpsertRuntimeConfigParams struct {
|
||||
Key string `db:"key" json:"key"`
|
||||
Value string `db:"value" json:"value"`
|
||||
}
|
||||
|
||||
func (q *sqlQuerier) UpsertRuntimeConfig(ctx context.Context, arg UpsertRuntimeConfigParams) error {
|
||||
_, err := q.db.ExecContext(ctx, upsertRuntimeConfig, arg.Key, arg.Value)
|
||||
return err
|
||||
}
|
||||
|
||||
const cleanTailnetCoordinators = `-- name: CleanTailnetCoordinators :exec
|
||||
DELETE
|
||||
FROM tailnet_coordinators
|
||||
|
||||
Reference in New Issue
Block a user