Documentation
¶
Index ¶
- Constants
- Variables
- type Data
- type Database
- func (d *Database) CloseDB()
- func (d *Database) DB() *sql.DB
- func (d *Database) DeleteBundle(ctx context.Context, principal, tenant, name string) error
- func (d *Database) DeleteSecret(ctx context.Context, principal, tenant, name string) error
- func (d *Database) DeleteSource(ctx context.Context, principal, tenant, name string) error
- func (d *Database) DeleteStack(ctx context.Context, principal, tenant, name string) error
- func (d *Database) Dialect() (string, error)
- func (d *Database) GetBundle(ctx context.Context, principal, tenant, name string) (*config.Bundle, error)
- func (d *Database) GetBundleStatus(ctx context.Context, id int) (*config.BundleStatus, error)
- func (d *Database) GetLatestBundleStatus(ctx context.Context, principal, tenant, bundle string) (*config.BundleStatus, error)
- func (db *Database) GetPrincipalID(ctx context.Context, apiKey string) (string, error)
- func (d *Database) GetSecret(ctx context.Context, principal, tenant, name string) (*config.SecretRef, error)
- func (d *Database) GetSource(ctx context.Context, principal, tenant, name string) (*config.Source, error)
- func (d *Database) GetStack(ctx context.Context, principal, tenant, name string) (*config.Stack, error)
- func (d *Database) InitDB(ctx context.Context) error
- func (d *Database) ListBundleStatuses(ctx context.Context, principal, tenant, bundle, revision string, limit int) ([]*config.BundleStatus, error)
- func (d *Database) ListBundles(ctx context.Context, principal, tenant string, opts ListOptions) ([]*config.Bundle, string, error)
- func (d *Database) ListSecrets(ctx context.Context, principal, tenant string, opts ListOptions) ([]*config.SecretRef, string, error)
- func (d *Database) ListSources(ctx context.Context, principal, tenant string, opts ListOptions) ([]*config.Source, string, error)
- func (d *Database) ListStacks(ctx context.Context, principal, tenant string, opts ListOptions) ([]*config.Stack, string, error)
- func (d *Database) LoadConfig(ctx context.Context, bar *progress.Bar, principal, tenant string, ...) error
- func (d *Database) QuerySourceData(sourceID int64, sourceName string) func(context.Context) iter.Seq2[Data, error]
- func (d *Database) QuerySourceID(ctx context.Context, tenant, sourceName string) (int64, error)
- func (d *Database) SourcesDataDelete(ctx context.Context, sourceName, path string, principal, tenant string) error
- func (d *Database) SourcesDataGet(ctx context.Context, sourceName, path string, principal, tenant string) (any, bool, error)
- func (d *Database) SourcesDataPatch(ctx context.Context, sourceName, path string, principal, tenant string, ...) error
- func (d *Database) SourcesDataPut(ctx context.Context, sourceName, path string, data any, ...) error
- func (d *Database) Tenants(ctx context.Context) iter.Seq2[Tenant, error]
- func (d *Database) UpsertBundle(ctx context.Context, principal, tenant string, bundle *config.Bundle) error
- func (d *Database) UpsertBundleStatus(ctx context.Context, tenant, bundle, revision, phase, status, errMsg string) (int, error)
- func (db *Database) UpsertPrincipal(ctx context.Context, principal Principal) error
- func (db *Database) UpsertPrincipalTx(ctx context.Context, tx *sql.Tx, principal Principal) error
- func (d *Database) UpsertSecret(ctx context.Context, principal, tenant string, secret *config.Secret) error
- func (d *Database) UpsertSource(ctx context.Context, principal, tenant string, source *config.Source) error
- func (d *Database) UpsertStack(ctx context.Context, principal, tenant string, stack *config.Stack) error
- func (d *Database) UpsertToken(ctx context.Context, principal, tenant string, token *config.Token) error
- func (d *Database) WithAccessFactory(accessFactory ext_authz.AccessFactory) *Database
- func (d *Database) WithAuthorizer(authorizer ext_authz.Authorizer) *Database
- func (d *Database) WithConfig(config *config.Database) *Database
- func (d *Database) WithLogger(log *logging.Logger) *Database
- func (d *Database) WithRawRootConfig(rawRootConfig []byte) *Database
- type ListOptions
- type Principal
- type Tenant
Constants ¶
const MaxBundleStatusRetention = 10
const SQLiteMemoryOnlyDSN = "file::memory:?cache=shared"
Variables ¶
var ErrNotAuthorized = errors.New("not authorized")
var ErrNotFound = errors.New("not found")
Functions ¶
This section is empty.
Types ¶
type Database ¶
type Database struct {
// contains filtered or unexported fields
}
Database implements the database operations. It will hide any differences between the varying SQL databases from the rest of the codebase.
func (*Database) DeleteBundle ¶
func (*Database) DeleteSecret ¶
func (*Database) DeleteSource ¶
func (*Database) DeleteStack ¶
func (*Database) GetBundleStatus ¶ added in v0.6.0
GetBundleStatus retrieves a single bundle state record by ID.
func (*Database) GetLatestBundleStatus ¶ added in v0.6.0
func (d *Database) GetLatestBundleStatus(ctx context.Context, principal, tenant, bundle string) (*config.BundleStatus, error)
GetLatestBundleStatus returns the most recent status record for the given tenant and bundle across all revisions. Returns nil and ErrNotFound if no records exist.
func (*Database) GetPrincipalID ¶
func (*Database) ListBundleStatuses ¶ added in v0.6.0
func (d *Database) ListBundleStatuses(ctx context.Context, principal, tenant, bundle, revision string, limit int) ([]*config.BundleStatus, error)
ListBundleStatuses returns bundle status records for the given tenant and bundle, ordered by bundle status id DESC. If revision is provided, results are filtered by revision. If revision is empty, returns records across all revisions. A limit of 0 defaults to MaxBundleStatusRetention; values above MaxBundleStatusRetention are capped.
func (*Database) ListBundles ¶
func (*Database) ListSecrets ¶
func (*Database) ListSources ¶
func (d *Database) ListSources(ctx context.Context, principal, tenant string, opts ListOptions) ([]*config.Source, string, error)
ListSources returns a list of sources in the database. Note it does not return the source data.
func (*Database) ListStacks ¶
func (*Database) LoadConfig ¶
func (d *Database) LoadConfig(ctx context.Context, bar *progress.Bar, principal, tenant string, root *config.Root) error
LoadConfig loads the configuration from the configuration file into the database. Env vars for values are getting resolved at this point. We don't store "${ADMIN_TOKEN}" in the DB, but lookup the current field. Failing lookups are treated as errors! Secrets are the exception: they are stored as-is, so if their value refers to an env var, it's replaced on use.
func (*Database) QuerySourceData ¶
func (*Database) QuerySourceID ¶ added in v0.3.0
func (*Database) SourcesDataDelete ¶
func (*Database) SourcesDataGet ¶
func (*Database) SourcesDataPatch ¶
func (*Database) SourcesDataPut ¶
func (*Database) UpsertBundle ¶
func (*Database) UpsertBundleStatus ¶ added in v0.6.0
func (d *Database) UpsertBundleStatus(ctx context.Context, tenant, bundle, revision, phase, status, errMsg string) (int, error)
UpsertBundleStatus creates or updates a bundle status record with the given phase and status. For a given tenant+bundle+revision combination, only one record exists. If a record already exists for the combination, it updates the phase and status. Old records beyond the retention limit (MaxBundleStatusRetention) are cleaned up in the same transaction.
func (*Database) UpsertPrincipal ¶
func (*Database) UpsertPrincipalTx ¶
func (*Database) UpsertSecret ¶
func (*Database) UpsertSource ¶
func (*Database) UpsertStack ¶
func (*Database) UpsertToken ¶
func (*Database) WithAccessFactory ¶ added in v0.4.0
func (d *Database) WithAccessFactory(accessFactory ext_authz.AccessFactory) *Database
func (*Database) WithAuthorizer ¶ added in v0.4.0
func (d *Database) WithAuthorizer(authorizer ext_authz.Authorizer) *Database