Documentation
¶
Overview ¶
Package cli provides shared runners and command builders for stage commands.
Index ¶
- func NewAddCommand(cfg CommandConfig) *cli.Command
- func NewApplyCommand(cfg CommandConfig) *cli.Command
- func NewDeleteCommand(cfg CommandConfig) *cli.Command
- func NewDiffCommand(cfg CommandConfig) *cli.Command
- func NewEditCommand(cfg CommandConfig) *cli.Command
- func NewExportCommand(cfg CommandConfig) *cli.Command
- func NewGlobalApplyCommand(gcfg GlobalConfig) *cli.Command
- func NewGlobalDiffCommand(gcfg GlobalConfig) *cli.Command
- func NewGlobalExportCommand(gcfg GlobalConfig) *cli.Command
- func NewGlobalImportCommand(gcfg GlobalConfig) *cli.Command
- func NewGlobalResetCommand(gcfg GlobalConfig) *cli.Command
- func NewGlobalStatusCommand(gcfg GlobalConfig) *cli.Command
- func NewImportCommand(cfg CommandConfig) *cli.Command
- func NewResetCommand(cfg CommandConfig) *cli.Command
- func NewStatusCommand(cfg CommandConfig) *cli.Command
- func NewTagCommand(cfg CommandConfig) *cli.Command
- func NewUntagCommand(cfg CommandConfig) *cli.Command
- func SharedScopeResolver(resolver staging.ScopeResolver) staging.ScopeResolver
- type CommandConfig
- type GlobalConfig
- type GlobalServiceSpec
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewAddCommand ¶
func NewAddCommand(cfg CommandConfig) *cli.Command
NewAddCommand creates an add command with the given config.
func NewApplyCommand ¶
func NewApplyCommand(cfg CommandConfig) *cli.Command
NewApplyCommand creates an apply command with the given config.
func NewDeleteCommand ¶
func NewDeleteCommand(cfg CommandConfig) *cli.Command
NewDeleteCommand creates a delete command with the given config.
func NewDiffCommand ¶
func NewDiffCommand(cfg CommandConfig) *cli.Command
NewDiffCommand creates a diff command with the given config.
func NewEditCommand ¶
func NewEditCommand(cfg CommandConfig) *cli.Command
NewEditCommand creates an edit command with the given config.
func NewExportCommand ¶ added in v1.7.0
func NewExportCommand(cfg CommandConfig) *cli.Command
NewExportCommand creates a service-specific `stage <svc> export <file>` command that writes the single service to <file>.
func NewGlobalApplyCommand ¶ added in v1.10.0
func NewGlobalApplyCommand(gcfg GlobalConfig) *cli.Command
NewGlobalApplyCommand creates the provider-wide `stage apply` command.
func NewGlobalDiffCommand ¶ added in v1.10.0
func NewGlobalDiffCommand(gcfg GlobalConfig) *cli.Command
NewGlobalDiffCommand creates the provider-wide `stage diff` command.
func NewGlobalExportCommand ¶ added in v1.7.0
func NewGlobalExportCommand(gcfg GlobalConfig) *cli.Command
NewGlobalExportCommand creates the global `stage export <dir>` command. It writes <dir>/param.json and <dir>/secret.json, one file per service that has staged changes (empty services are skipped). The resolver determines the provider staging scope; its CommandPath renders the help examples.
func NewGlobalImportCommand ¶ added in v1.7.0
func NewGlobalImportCommand(gcfg GlobalConfig) *cli.Command
NewGlobalImportCommand creates the global `stage import <dir>` command. It reads <dir>/param.json and <dir>/secret.json (missing files are skipped; an error only when neither exists) into the working staging area. The config's ScopeResolver determines the provider staging scope; its per-service factories re-anchor conflict-detection timestamps on a cross-scope import.
func NewGlobalResetCommand ¶ added in v1.10.0
func NewGlobalResetCommand(gcfg GlobalConfig) *cli.Command
NewGlobalResetCommand creates the provider-wide `stage reset` command.
func NewGlobalStatusCommand ¶ added in v1.10.0
func NewGlobalStatusCommand(gcfg GlobalConfig) *cli.Command
NewGlobalStatusCommand creates the provider-wide `stage status` command.
func NewImportCommand ¶ added in v1.7.0
func NewImportCommand(cfg CommandConfig) *cli.Command
NewImportCommand creates a service-specific `stage <svc> import <file>` command that reads the single service from <file>. A service mismatch (the file holds another service) is a hard error.
func NewResetCommand ¶
func NewResetCommand(cfg CommandConfig) *cli.Command
NewResetCommand creates a reset command with the given config.
func NewStatusCommand ¶
func NewStatusCommand(cfg CommandConfig) *cli.Command
NewStatusCommand creates a status command with the given config.
func NewTagCommand ¶
func NewTagCommand(cfg CommandConfig) *cli.Command
NewTagCommand creates a tag command with the given config.
func NewUntagCommand ¶
func NewUntagCommand(cfg CommandConfig) *cli.Command
NewUntagCommand creates an untag command with the given config.
func SharedScopeResolver ¶ added in v1.10.0
func SharedScopeResolver(resolver staging.ScopeResolver) staging.ScopeResolver
SharedScopeResolver wraps a resolver that several services of one provider share (AWS Parameter Store and Secrets Manager resolve one account scope from the STS caller identity). Within one all-service command it runs once, and the other services reuse its result (or error). Outside those commands it just calls resolver.
Types ¶
type CommandConfig ¶
type CommandConfig struct {
// CommandName is the subcommand name (e.g., "param", "secret").
CommandName string
// ItemName is the item name for messages (e.g., "parameter", "secret").
ItemName string
// ProviderLabel is the human-readable provider name used in help text,
// prompts, and messages (e.g., "AWS", "Google Cloud", "Azure").
ProviderLabel string
// CommandPath is the explicit command path of this service's stage group,
// used in help examples and usage errors (e.g., "suve aws stage param",
// "suve gcloud stage", "suve azure stage secret").
CommandPath string
// Factory creates a FullStrategy backed by a provider.Store.
Factory staging.StrategyFactory
// ParserFactory creates a Parser without provider access (for status, parsing).
ParserFactory staging.ParserFactory
// ScopeResolver resolves the provider staging scope used to key on-disk
// state. Required: a nil resolver makes every staging command fail.
ScopeResolver staging.ScopeResolver
// HasDescription reports whether this service's writer honors a free-text
// description (AWS param/secret and Google Cloud secret). When true, `stage
// add`/`stage edit` register a --description flag; when false the flag is not
// registered at all, so a description on an unsupported provider (Azure Key
// Vault / App Configuration) is rejected as an unknown flag rather than being
// accepted and then silently dropped on apply.
HasDescription bool
// Namespace resolves the App Configuration namespace a single-item staging
// op targets, from the command context (the --namespace flag). It records
// the namespace on the staged entry as part of its identity. Nil for
// providers without a namespace axis (the namespace is then always empty).
Namespace func(ctx context.Context) string
// StrategyForNamespace builds a strategy backed by a provider store scoped to
// the given namespace, so status/diff/apply act on each staged entry under
// its own namespace (App Configuration keeps all namespaces in one staging
// store). Nil for providers without a namespace axis.
StrategyForNamespace func(ctx context.Context, namespace string) (staging.FullStrategy, error)
// ValueTypeFlags are provider-specific flags appended to the add and edit
// commands so the staged entry can carry a value type (the AWS Parameter
// Store --type/--secure axis). Nil for providers without a value-type axis.
ValueTypeFlags []cli.Flag
// ValueTypeFromCmd validates and resolves the staged value type from the
// add/edit command flags (ValueTypeFlags). Nil for providers without a
// value-type axis, in which case the staged value type is left unset. An
// empty return means "not specified": create applies plaintext and update
// preserves the existing type.
ValueTypeFromCmd func(cmd *cli.Command) (domain.ValueType, error)
}
CommandConfig holds service-specific configuration for building stage commands.
type GlobalConfig ¶ added in v0.8.1
type GlobalConfig struct {
// ProviderLabel is the human-readable provider name used in prompts and
// messages (e.g. "AWS", "Azure").
ProviderLabel string
// CommandPath is the explicit command path of the provider's stage group,
// used in help text and usage errors (e.g. "suve aws stage").
CommandPath string
// ScopeResolver resolves the one provider staging scope that the all-service
// export/import (NewGlobalExportCommand / NewGlobalImportCommand) read and
// write. Required when those commands are wired; status / diff / apply /
// reset use each service's own ScopeResolver instead.
ScopeResolver staging.ScopeResolver
// Services lists the provider's services in stable display order.
Services []GlobalServiceSpec
}
GlobalConfig configures the provider-wide stage commands so a single set of implementations serves every multi-service provider: AWS and Azure each iterate param + secret, each service through its own ScopeResolver.
type GlobalServiceSpec ¶ added in v0.8.1
type GlobalServiceSpec struct {
// Service is the staging service (param or secret).
Service staging.Service
// ParserFactory builds a network-free parser for this service.
ParserFactory staging.ParserFactory
// Factory builds a provider-backed strategy for this service.
Factory staging.StrategyFactory
// ScopeResolver resolves THIS service's staging scope. It is per-service
// because a provider's services may live in independent resources with
// separate staging buckets: Azure App Configuration (param) is keyed by
// store name, Key Vault (secret) by vault name. AWS keeps one account scope
// for both; wrap such a shared resolver in SharedScopeResolver so the
// all-service commands resolve it once. Required.
ScopeResolver staging.ScopeResolver
// StrategyForNamespace, when set, builds a strategy scoped to a given
// namespace so apply/diff act on each staged entry under its own namespace
// (Azure App Configuration keeps all namespaces in one staging store). Nil
// for services without a namespace axis — the single Factory strategy is used.
StrategyForNamespace func(ctx context.Context, namespace string) (staging.FullStrategy, error)
}
GlobalServiceSpec describes one service for the provider-wide (all-service) stage commands (status / diff / apply / reset in global_*.go). ParserFactory yields a network-free Parser (service name, delete-option support); Factory builds a FullStrategy backed by a provider.Store for apply/diff.