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 NewGlobalStashCommand(resolver staging.ScopeResolver) *cli.Command
- func NewResetCommand(cfg CommandConfig) *cli.Command
- func NewStashCommand(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 GlobalDropRunner
- type GlobalServiceSpec
- type ResetOptions
- type ResetRunner
- type ServiceDropRunner
- type StashPopModeChooser
- type StashPopModeInput
- type StashPopModeResult
- type StashPopOptions
- type StashPopRunner
- type StashPushOptions
- type StashPushRunner
- type StashShowOptions
- type StashShowRunner
- 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 NewGlobalStashCommand ¶
func NewGlobalStashCommand(resolver staging.ScopeResolver) *cli.Command
NewGlobalStashCommand creates a global stash command group that operates on all services. The resolver determines the provider staging scope (nil defaults to AWS).
func NewResetCommand ¶
func NewResetCommand(cfg CommandConfig) *cli.Command
NewResetCommand creates a reset command with the given config.
func NewStashCommand ¶
func NewStashCommand(cfg CommandConfig) *cli.Command
NewStashCommand creates a service-specific stash command group 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 (single-file) global stash under App Configuration; cross-resource stash is tracked separately (#435).
type GlobalDropRunner ¶ added in v0.7.3
GlobalDropRunner executes global stash drop (delete entire file).
func (*GlobalDropRunner) Run ¶ added in v0.7.3
func (r *GlobalDropRunner) Run() error
Run deletes the stash file without reading its contents.
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 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 ServiceDropRunner ¶ added in v0.7.3
ServiceDropRunner executes service-specific stash drop.
type StashPopModeChooser ¶ added in v0.7.3
StashPopModeChooser determines the stash pop mode based on flags and user input.
func (*StashPopModeChooser) ChooseMode ¶ added in v0.7.3
func (c *StashPopModeChooser) ChooseMode(input StashPopModeInput) (StashPopModeResult, error)
ChooseMode determines the stash pop mode, prompting interactively if needed.
type StashPopModeInput ¶ added in v0.7.3
type StashPopModeInput struct {
MergeFlag bool
OverwriteFlag bool
HasChanges bool
ItemCount int
IsTTY bool
}
StashPopModeInput holds the input for determining stash pop mode.
type StashPopModeResult ¶ added in v0.7.3
type StashPopModeResult struct {
Mode stagingusecase.StashMode
Cancelled bool
}
StashPopModeResult holds the result of mode selection.
type StashPopOptions ¶
type StashPopOptions struct {
// Service filters the operation to a specific service. Empty means all services.
Service staging.Service
// Keep preserves the file after popping.
Keep bool
// Mode determines how to handle conflicts with the existing working staging area.
Mode stagingusecase.StashMode
}
StashPopOptions holds options for the stash pop command.
type StashPopRunner ¶
type StashPopRunner struct {
UseCase *stagingusecase.StashPopUseCase
Stdout io.Writer
Stderr io.Writer
}
StashPopRunner executes stash pop operations using a usecase.
func (*StashPopRunner) Run ¶
func (r *StashPopRunner) Run(ctx context.Context, opts StashPopOptions) error
Run executes the stash pop command.
type StashPushOptions ¶
type StashPushOptions struct {
// Service filters the operation to a specific service. Empty means all services.
Service staging.Service
// Keep preserves the working staging area after pushing to the stash file.
Keep bool
// Mode determines how to handle existing stash file.
Mode usestaging.StashMode
}
StashPushOptions holds options for the stash push command.
type StashPushRunner ¶
type StashPushRunner struct {
UseCase *usestaging.StashPushUseCase
Stdout io.Writer
Stderr io.Writer
Encrypted bool // Whether the file is encrypted (for output messages)
}
StashPushRunner executes stash push operations using a usecase.
func (*StashPushRunner) Run ¶
func (r *StashPushRunner) Run(ctx context.Context, opts StashPushOptions) error
Run executes the stash push command.
type StashShowOptions ¶
type StashShowOptions struct {
// Service filters the display to a specific service. Empty means all services.
Service staging.Service
// Verbose shows detailed information.
Verbose bool
}
StashShowOptions holds options for the stash show command.
type StashShowRunner ¶
StashShowRunner executes stash show operations.
func (*StashShowRunner) Run ¶
func (r *StashShowRunner) Run(ctx context.Context, opts StashShowOptions) error
Run executes the stash show 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.