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
@@ -0,0 +1,39 @@
|
||||
package runtimeconfig
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"golang.org/x/xerrors"
|
||||
|
||||
"github.com/coder/coder/v2/coderd/database"
|
||||
)
|
||||
|
||||
var (
|
||||
// ErrEntryNotFound is returned when a runtime entry is not saved in the
|
||||
// store. It is essentially a 'sql.ErrNoRows'.
|
||||
ErrEntryNotFound = xerrors.New("entry not found")
|
||||
// ErrNameNotSet is returned when a runtime entry is created without a name.
|
||||
// This is more likely to happen on DeploymentEntry that has not called
|
||||
// Initialize().
|
||||
ErrNameNotSet = xerrors.New("name is not set")
|
||||
)
|
||||
|
||||
type Initializer interface {
|
||||
Initialize(name string)
|
||||
}
|
||||
|
||||
type Resolver interface {
|
||||
// GetRuntimeConfig gets a runtime setting by name.
|
||||
GetRuntimeConfig(ctx context.Context, name string) (string, error)
|
||||
// UpsertRuntimeConfig upserts a runtime setting by name.
|
||||
UpsertRuntimeConfig(ctx context.Context, name, val string) error
|
||||
// DeleteRuntimeConfig deletes a runtime setting by name.
|
||||
DeleteRuntimeConfig(ctx context.Context, name string) error
|
||||
}
|
||||
|
||||
// Store is a subset of database.Store
|
||||
type Store interface {
|
||||
GetRuntimeConfig(ctx context.Context, key string) (string, error)
|
||||
UpsertRuntimeConfig(ctx context.Context, arg database.UpsertRuntimeConfigParams) error
|
||||
DeleteRuntimeConfig(ctx context.Context, key string) error
|
||||
}
|
||||
Reference in New Issue
Block a user