Documentation
¶
Overview ¶
Package workflow defines the contract between the cleanup-sweeper command and its cleanup workflows. Workflow-specific settings are declared by each workflow itself and supplied as --options=<workflow>.<key>=<value>.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Common ¶
type Common struct {
// DryRun previews what would be deleted without changing anything.
DryRun bool
// Parallelism bounds concurrent deletions per step.
Parallelism int
// Timeout bounds the whole run; zero means the workflow's own default, if any.
Timeout time.Duration
// PolicyFile is the policy document for the selected workflow, for the
// workflows that take one.
PolicyFile string
}
Common holds the options that apply to every workflow.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry holds the available workflows and the options each declares.
func NewRegistry ¶
NewRegistry registers workflows in the supplied order, rejecting nil workflows and empty, whitespace-padded or duplicate names, and lets each workflow declare its options.
func (*Registry) ApplyOptions ¶
ApplyOptions sets the selected workflow's options from entries of the form "<workflow>.<key>=<value>". Keys are the names the workflow declared, and later entries override earlier ones (list-valued options accumulate). An unknown workflow, an option meant for a different workflow than the selected one, an unknown key, or a value the option rejects is an error.
func (*Registry) OptionsUsage ¶
OptionsUsage describes every option declared by the registered workflows, grouped by workflow, for command help.
type Workflow ¶
type Workflow interface {
// Name is the value of --workflow selecting this workflow and the <workflow>
// prefix of its options.
Name() string
// AttachOptions declares the options this workflow accepts through
// --options=<name>.<key>=<value>. The workflow owns each option's key,
// default and help; workflows without options declare nothing.
AttachOptions(flags *pflag.FlagSet)
// Validate checks the applied options and the common options, including
// loading the policy file, before any credential is created.
Validate(common Common) error
// LogValues returns key/value pairs, such as the target subscription, that
// identify what the workflow acts on. The command adds them to every log entry.
LogValues() []any
// Run executes the workflow.
Run(ctx context.Context, common Common, credential azcore.TokenCredential) error
}
Workflow is one cleanup workflow. A Workflow value holds the state its own options are bound to, so every command invocation needs its own instances.