Documentation
¶
Overview ¶
Package app wires configuration, the stores and the HTTP server together. cmd/artifactweave stays a thin cobra shim and calls Run; tests drive Run with a fake handler.
Index ¶
- Constants
- Variables
- func ApplyDescriptor(ctx context.Context, cfg config.Config, file string, dryRun bool, w io.Writer) error
- func Keyring(cfg config.Config) (*crypt.Keyring, error)
- func Migrate(ctx context.Context, cfg config.Config, action string, to int, w io.Writer) error
- func OpenStore(ctx context.Context, cfg config.Config, o sqlcommon.Options) (*sqlcommon.Store, error)
- func RotateKeys(ctx context.Context, cfg config.Config, w io.Writer) error
- func Run(ctx context.Context, cfg config.Config, log *slog.Logger) error
Constants ¶
const InitialPasswordFile = "initial-admin-password"
InitialPasswordFile is where the first start writes a generated admin password, under the data directory. A file with mode 0600 rather than a log line, because logs are shipped and kept where the password must not be.
Variables ¶
var ErrUnknownMigration = errors.New("unknown migrate action")
ErrUnknownMigration reports a migrate action other than up, down or version.
Functions ¶
func ApplyDescriptor ¶
func ApplyDescriptor( ctx context.Context, cfg config.Config, file string, dryRun bool, w io.Writer, ) error
ApplyDescriptor runs `artifactweave config apply`: it applies the descriptor in file to the store the configuration names, as `migrate` and `keys rotate` work on the store directly, and writes what changed to w. With dryRun it checks the whole descriptor against the current state and writes nothing.
It works on the store rather than calling a running server so that it needs no admin credentials in the CI job, only the configuration the server itself uses, and so that it can prepare a store before the first start. It runs the same code as PATCH /api/system/configuration.
func Keyring ¶
Keyring builds the keyring from master_key and, during a rotation, master_key_previous (crypt.ParseVersionedKey). It returns nil without error when no master key is configured, for the commands that run without one.
func Migrate ¶
Migrate runs `artifactweave migrate <action>`: "up" applies every pending migration, "down" reverts those newer than to (one step when to is negative, everything when it is 0), and "version" reports the applied and latest versions. It writes one line of outcome to w.
func OpenStore ¶
func OpenStore( ctx context.Context, cfg config.Config, o sqlcommon.Options, ) (*sqlcommon.Store, error)
OpenStore opens the configured metadata store. The SQLite file's directory is created when missing, so a first start needs nothing but a data directory path.
func RotateKeys ¶
RotateKeys runs `artifactweave keys rotate`: it opens the store with the configured keyring (master_key and master_key_previous), re-seals every sealed value under the newest version and reports how many changed. Once it has run, master_key_previous can be removed.
Types ¶
This section is empty.