database

package
v0.0.0-...-ff134b0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 12, 2025 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const SQLiteMemoryOnlyDSN = "file::memory:?cache=shared"

Variables

View Source
var ErrNotAuthorized = errors.New("not authorized")
View Source
var ErrNotFound = errors.New("not found")

Functions

This section is empty.

Types

type Data

type Data struct {
	Path string `sql:"path"`
	Data []byte `sql:"data"`
}

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) CloseDB

func (d *Database) CloseDB()

func (*Database) DB

func (d *Database) DB() *sql.DB

func (*Database) DeleteBundle

func (d *Database) DeleteBundle(ctx context.Context, principal string, name string) error

func (*Database) DeleteSecret

func (d *Database) DeleteSecret(ctx context.Context, principal string, name string) error

func (*Database) DeleteSource

func (d *Database) DeleteSource(ctx context.Context, principal string, name string) error

func (*Database) DeleteStack

func (d *Database) DeleteStack(ctx context.Context, principal string, name string) error

func (*Database) Dialect

func (d *Database) Dialect() (string, error)

func (*Database) GetBundle

func (d *Database) GetBundle(ctx context.Context, principal string, name string) (*config.Bundle, error)

func (*Database) GetPrincipalID

func (db *Database) GetPrincipalID(ctx context.Context, apiKey string) (string, error)

func (*Database) GetSecret

func (d *Database) GetSecret(ctx context.Context, principal string, name string) (*config.SecretRef, error)

func (*Database) GetSource

func (d *Database) GetSource(ctx context.Context, principal string, name string) (*config.Source, error)

func (*Database) GetStack

func (d *Database) GetStack(ctx context.Context, principal string, name string) (*config.Stack, error)

func (*Database) InitDB

func (d *Database) InitDB(ctx context.Context) error

func (*Database) ListBundles

func (d *Database) ListBundles(ctx context.Context, principal string, opts ListOptions) ([]*config.Bundle, string, error)

func (*Database) ListSecrets

func (d *Database) ListSecrets(ctx context.Context, principal string, opts ListOptions) ([]*config.SecretRef, string, error)

func (*Database) ListSources

func (d *Database) ListSources(ctx context.Context, principal 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 (d *Database) ListStacks(ctx context.Context, principal string, opts ListOptions) ([]*config.Stack, string, error)

func (*Database) LoadConfig

func (d *Database) LoadConfig(ctx context.Context, bar *progress.Bar, principal 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 (d *Database) QuerySourceData(sourceName string) func(context.Context) iter.Seq2[Data, error]

func (*Database) SourcesDataDelete

func (d *Database) SourcesDataDelete(ctx context.Context, sourceName, path string, principal string) error

func (*Database) SourcesDataGet

func (d *Database) SourcesDataGet(ctx context.Context, sourceName, path string, principal string) (any, bool, error)

func (*Database) SourcesDataPatch

func (d *Database) SourcesDataPatch(ctx context.Context, sourceName, path string, principal string, patch jsonpatch.Patch) error

func (*Database) SourcesDataPut

func (d *Database) SourcesDataPut(ctx context.Context, sourceName, path string, data any, principal string) error

func (*Database) UpsertBundle

func (d *Database) UpsertBundle(ctx context.Context, principal string, bundle *config.Bundle) error

func (*Database) UpsertPrincipal

func (db *Database) UpsertPrincipal(ctx context.Context, principal Principal) error

func (*Database) UpsertPrincipalTx

func (db *Database) UpsertPrincipalTx(ctx context.Context, tx *sql.Tx, principal Principal) error

func (*Database) UpsertSecret

func (d *Database) UpsertSecret(ctx context.Context, principal string, secret *config.Secret) error

func (*Database) UpsertSource

func (d *Database) UpsertSource(ctx context.Context, principal string, source *config.Source) error

func (*Database) UpsertStack

func (d *Database) UpsertStack(ctx context.Context, principal string, stack *config.Stack) error

func (*Database) UpsertToken

func (d *Database) UpsertToken(ctx context.Context, principal string, token *config.Token) error

func (*Database) WithConfig

func (d *Database) WithConfig(config *config.Database) *Database

func (*Database) WithLogger

func (d *Database) WithLogger(log *logging.Logger) *Database

type ListOptions

type ListOptions struct {
	Limit  int
	Cursor string
	// contains filtered or unexported fields
}

type Principal

type Principal struct {
	Id        string
	Role      string
	CreatedAt string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL