Documentation
¶
Overview ¶
Package cli provides shared runners and command builders for stage commands.
Index ¶
- func AWSScopeResolver(ctx context.Context) (staging.ResolvedScope, error)
- func FormatTagApplySummary(tag stagingusecase.ApplyTagResult) string
- 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 NewGlobalExportCommand(resolver staging.ScopeResolver) *cli.Command
- func NewGlobalImportCommand(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 WorkingStore(ctx context.Context, resolver staging.ScopeResolver) (*file.Store, staging.ResolvedScope, error)
- type AddOptions
- type AddRunner
- type ApplyOptions
- type ApplyRunner
- type CommandConfig
- type DeleteOptions
- type DeleteRunner
- type DiffOptions
- type DiffRunner
- func (r *DiffRunner) OutputDiff(opts DiffOptions, entry stagingusecase.DiffEntry)
- func (r *DiffRunner) OutputDiffCreate(opts DiffOptions, entry stagingusecase.DiffEntry)
- func (r *DiffRunner) OutputMetadata(entry stagingusecase.DiffEntry)
- func (r *DiffRunner) OutputTagEntry(tagEntry stagingusecase.DiffTagEntry)
- func (r *DiffRunner) Run(ctx context.Context, opts DiffOptions) error
- type EditOptions
- type EditRunner
- type GlobalConfig
- type GlobalServiceSpec
- type ImportModeChooser
- type ImportModeInput
- type ImportModeResult
- type ResetOptions
- type ResetRunner
- type StatusOptions
- type StatusRunner
- type TagOptions
- type TagRunner
- type UntagOptions
- type UntagRunner
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AWSScopeResolver ¶ added in v0.8.1
func AWSScopeResolver(ctx context.Context) (staging.ResolvedScope, error)
AWSScopeResolver resolves the AWS staging scope from the STS caller identity. It is the default resolver used when a CommandConfig / GlobalConfig does not specify one, preserving the original AWS-only staging behavior.
func FormatTagApplySummary ¶
func FormatTagApplySummary(tag stagingusecase.ApplyTagResult) string
FormatTagApplySummary formats a tag apply result as a summary string.
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 NewGlobalExportCommand ¶ added in v1.7.0
func NewGlobalExportCommand(resolver staging.ScopeResolver) *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 (nil defaults to AWS).
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 (nil defaults to AWS); its per-service factories re-anchor conflict-detection timestamps on a cross-scope import.
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 WorkingStore ¶ added in v0.8.1
func WorkingStore(ctx context.Context, resolver staging.ScopeResolver) (*file.Store, staging.ResolvedScope, error)
WorkingStore resolves the staging scope via the resolver (default AWS) and opens the working store keyed by that scope. It is the exported entry point used by the provider-wide (all-service) stage commands.
Types ¶
type AddOptions ¶
type AddOptions struct {
Name string
Value string // Optional: if set, skip editor and use this value
Description string
// Namespace is the App Configuration namespace to stage under (empty for the
// null/default namespace and every other provider).
Namespace string
}
AddOptions holds options for the add command.
type AddRunner ¶
type AddRunner struct {
UseCase *stagingusecase.AddUseCase
Stdout io.Writer
Stderr io.Writer
OpenEditor editor.OpenFunc // Optional: defaults to editor.Open if nil
}
AddRunner executes add operations using a usecase.
type ApplyOptions ¶
type ApplyOptions struct {
Name string // Optional: apply only this item, otherwise apply all
IgnoreConflicts bool // Skip conflict detection and force apply
}
ApplyOptions holds options for the apply command.
type ApplyRunner ¶
type ApplyRunner struct {
UseCase *stagingusecase.ApplyUseCase
Store store.ReadWriteOperator
Parser staging.Parser
Confirmer confirmer
SkipConfirm bool
Stdout io.Writer
Stderr io.Writer
}
ApplyRunner applies staged changes via the ApplyUseCase and reports the results. RunInteractive wraps Run with the presentation-layer orchestration (empty-check, name validation, and interactive confirmation) that the `stage <service> apply` command performs before applying.
func (*ApplyRunner) Run ¶
func (r *ApplyRunner) Run(ctx context.Context, opts ApplyOptions) error
Run applies the staged changes via the usecase and reports the results.
func (*ApplyRunner) RunInteractive ¶ added in v0.8.0
func (r *ApplyRunner) RunInteractive(ctx context.Context, opts ApplyOptions) error
RunInteractive performs the command-level apply flow: it lists staged entries, short-circuits when nothing is staged, validates an optional target name, asks for confirmation, and then delegates to Run. Interactive confirmation lives here (presentation layer) rather than in the usecase.
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
// 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. When nil, it defaults to AWSScopeResolver, preserving AWS behavior.
ScopeResolver staging.ScopeResolver
// 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)
}
CommandConfig holds service-specific configuration for building stage commands.
type DeleteOptions ¶
type DeleteOptions struct {
Name string
Force bool // For Secrets Manager: force immediate deletion
RecoveryWindow int // For Secrets Manager: days before permanent deletion (7-30)
// Namespace is the App Configuration namespace of the setting (empty for the
// null/default namespace and every other provider).
Namespace string
}
DeleteOptions holds options for the delete command.
type DeleteRunner ¶
type DeleteRunner struct {
UseCase *stagingusecase.DeleteUseCase
Stdout io.Writer
Stderr io.Writer
}
DeleteRunner executes delete operations using a usecase.
func (*DeleteRunner) Run ¶
func (r *DeleteRunner) Run(ctx context.Context, opts DeleteOptions) error
Run executes the delete command.
type DiffOptions ¶
type DiffOptions struct {
Name string // Optional: diff only this item, otherwise diff all
ParseJSON bool
NoPager bool
}
DiffOptions holds options for the diff command.
type DiffRunner ¶
type DiffRunner struct {
UseCase *stagingusecase.DiffUseCase
Stdout io.Writer
Stderr io.Writer
}
DiffRunner executes diff operations using a usecase.
func (*DiffRunner) OutputDiff ¶
func (r *DiffRunner) OutputDiff(opts DiffOptions, entry stagingusecase.DiffEntry)
OutputDiff outputs a diff entry for an existing resource.
func (*DiffRunner) OutputDiffCreate ¶
func (r *DiffRunner) OutputDiffCreate(opts DiffOptions, entry stagingusecase.DiffEntry)
OutputDiffCreate outputs a diff entry for a newly created resource.
func (*DiffRunner) OutputMetadata ¶
func (r *DiffRunner) OutputMetadata(entry stagingusecase.DiffEntry)
OutputMetadata outputs metadata for a diff entry.
func (*DiffRunner) OutputTagEntry ¶
func (r *DiffRunner) OutputTagEntry(tagEntry stagingusecase.DiffTagEntry)
OutputTagEntry outputs a tag entry.
func (*DiffRunner) Run ¶
func (r *DiffRunner) Run(ctx context.Context, opts DiffOptions) error
Run executes the diff command.
type EditOptions ¶
type EditOptions struct {
Name string
Value string // Optional: if set, skip editor and use this value
Description string
// Namespace is the App Configuration namespace of the setting (empty for the
// null/default namespace and every other provider).
Namespace string
}
EditOptions holds options for the edit command.
type EditRunner ¶
type EditRunner struct {
UseCase *stagingusecase.EditUseCase
Stdout io.Writer
Stderr io.Writer
OpenEditor editor.OpenFunc // Optional: defaults to editor.Open if nil
}
EditRunner executes edit operations using a usecase.
func (*EditRunner) Run ¶
func (r *EditRunner) Run(ctx context.Context, opts EditOptions) error
Run executes the edit command.
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", "Google Cloud").
ProviderLabel string
// ScopeResolver resolves the provider staging scope. Nil defaults to AWS.
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 provider: AWS iterates param + secret, Google Cloud iterates secret only. The ScopeResolver keys on-disk staging state for the active provider (nil defaults to AWS).
func AWSGlobalConfig ¶ added in v0.8.1
func AWSGlobalConfig(paramCfg, secretCfg CommandConfig) GlobalConfig
AWSGlobalConfig builds the GlobalConfig for AWS (param + secret) from the given service factories. It preserves the historical AWS behavior and wording.
func AzureGlobalConfig ¶ added in v1.6.0
func AzureGlobalConfig(paramCfg, secretCfg CommandConfig) GlobalConfig
AzureGlobalConfig builds the GlobalConfig for Azure. Unlike AWS, App Configuration (param) and Key Vault (secret) are INDEPENDENT resources with separate staging buckets, so each service carries its own ScopeResolver. The top-level ScopeResolver keys the global export/import scope under App Configuration; cross-resource scoping is tracked separately (#435).
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. Nil defaults to AWS (AWSScopeResolver).
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). ParserFactory yields a network-free Parser (service name, delete-option support); Factory builds a FullStrategy backed by a provider.Store for apply/diff.
type ImportModeChooser ¶ added in v1.7.0
ImportModeChooser resolves the reconciliation mode for the working staging area, mirroring the former stash-pop chooser: an explicit flag wins; otherwise a Merge/Overwrite/Cancel prompt appears only when the working area already holds changes and a TTY is available; the default is Merge.
func (*ImportModeChooser) ChooseMode ¶ added in v1.7.0
func (c *ImportModeChooser) ChooseMode(input ImportModeInput) (ImportModeResult, error)
ChooseMode determines the import mode, prompting interactively if needed.
type ImportModeInput ¶ added in v1.7.0
type ImportModeInput struct {
MergeFlag bool
OverwriteFlag bool
// SkipPrompt (--yes) accepts the default (Merge) without the interactive
// Merge/Overwrite/Cancel prompt, for scripts/automation.
SkipPrompt bool
// PassphraseStdin (--passphrase-stdin) means stdin carries the passphrase, not
// an interactive answer. Prompting would double-buffer/EOF against the
// passphrase read (#472), so the mode is resolved from flags only (default
// Merge) without prompting.
PassphraseStdin bool
HasChanges bool
ItemCount int
IsTTY bool
}
ImportModeInput holds the inputs to import-mode selection.
type ImportModeResult ¶ added in v1.7.0
type ImportModeResult struct {
Mode usestaging.ImportMode
Cancelled bool
}
ImportModeResult holds the outcome of import-mode selection.
type ResetOptions ¶
type ResetOptions struct {
Spec string // Name with optional version spec
All bool // Reset all staged items for this service
// Namespace is the App Configuration namespace of the entry to reset (empty
// for the null/default namespace and every other provider; ignored with All).
Namespace string
}
ResetOptions holds options for the reset command.
type ResetRunner ¶
type ResetRunner struct {
UseCase *stagingusecase.ResetUseCase
Stdout io.Writer
Stderr io.Writer
}
ResetRunner executes reset operations using a usecase.
func (*ResetRunner) Run ¶
func (r *ResetRunner) Run(ctx context.Context, opts ResetOptions) error
Run executes the reset command.
type StatusOptions ¶
StatusOptions holds options for the status command.
type StatusRunner ¶
type StatusRunner struct {
UseCase *stagingusecase.StatusUseCase
Stdout io.Writer
Stderr io.Writer
}
StatusRunner executes status operations using a usecase.
func (*StatusRunner) Run ¶
func (r *StatusRunner) Run(ctx context.Context, opts StatusOptions) error
Run executes the status command.
type TagOptions ¶
type TagOptions struct {
Name string
// Namespace is the App Configuration namespace of the resource (empty for the
// null/default namespace and every other provider).
Namespace string
Tags []string // key=value pairs to add
}
TagOptions holds options for the tag command.
type TagRunner ¶
type TagRunner struct {
UseCase *stagingusecase.TagUseCase
Stdout io.Writer
Stderr io.Writer
}
TagRunner executes tag staging operations using a usecase.
type UntagOptions ¶
type UntagOptions struct {
Name string
// Namespace is the App Configuration namespace of the resource (empty for the
// null/default namespace and every other provider).
Namespace string
Keys []string // tag keys to remove
}
UntagOptions holds options for the untag command.
type UntagRunner ¶
type UntagRunner struct {
UseCase *stagingusecase.TagUseCase
Stdout io.Writer
Stderr io.Writer
}
UntagRunner executes untag staging operations using a usecase.
func (*UntagRunner) Run ¶
func (r *UntagRunner) Run(ctx context.Context, opts UntagOptions) error
Run executes the untag command.