run

package
v0.38.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 25, 2026 License: Apache-2.0 Imports: 57 Imported by: 0

Documentation

Overview

Package run provides the CLI run commands. Business logic has been extracted to pkg/solution/execute for reuse across CLI, MCP, and future API layers.

Index

Constants

View Source
const ResolverParametersFlagHelp = `` /* 621-byte string literal not displayed */

ResolverParametersFlagHelp is the flag-only help text block for resolver parameter passing, used by run solution (which does not accept positional key=value parameters).

View Source
const ResolverParametersHelp = `` /* 1283-byte string literal not displayed */

ResolverParametersHelp is the help text block for resolver parameter passing conventions including positional args, used by run resolver.

Variables

View Source
var ValidOutputTypes = kvx.BaseOutputFormats()

ValidOutputTypes defines the supported output formats

Functions

func CommandAction added in v0.8.0

func CommandAction(cliParams *settings.Run, ioStreams *terminal.IOStreams, path string) *cobra.Command

CommandAction creates the 'run action' subcommand.

func CommandProvider added in v0.2.0

func CommandProvider(cliParams *settings.Run, ioStreams *terminal.IOStreams, path string) *cobra.Command

CommandProvider creates the 'run provider' subcommand

func CommandResolver added in v0.2.0

func CommandResolver(cliParams *settings.Run, ioStreams *terminal.IOStreams, path string) *cobra.Command

CommandResolver creates the 'run resolver' subcommand

func CommandRun

func CommandRun(cliParams *settings.Run, ioStreams *terminal.IOStreams, path string) *cobra.Command

CommandRun creates the 'run' command that executes solutions and other runnable artifacts.

func CommandSolution

func CommandSolution(cliParams *settings.Run, ioStreams *terminal.IOStreams, path string) *cobra.Command

CommandSolution creates the 'run solution' subcommand

func CommandValidateResolver added in v0.24.0

func CommandValidateResolver(cliParams *settings.Run, ioStreams *terminal.IOStreams, path string) *cobra.Command

CommandValidateResolver creates the 'validate resolver' subcommand. It reuses the resolver execution machinery but always treats validation failures as fatal (exit code 2), making it a validation gate suitable for CI. Unlike 'run resolver', it does not expose graph/snapshot modes — its sole purpose is to validate resolver outputs and report failures.

Types

type ActionOptions added in v0.8.0

type ActionOptions struct {
	BinaryName string

	// Names is the list of action names to execute (positional args).
	// Only the specified actions and their transitive dependsOn dependencies
	// are executed. Finally actions always run.
	Names []string

	// Action execution options
	ActionTimeout        time.Duration
	MaxActionConcurrency int
	DryRun               bool
	Verbose              bool
	ShowExecution        bool

	// File conflict strategy
	OnConflict string
	Force      bool
	Backup     bool

	// SkipFingerprint disables fingerprint-based up-to-date checks.
	SkipFingerprint bool

	// DynamicArgs are resolver parameters from positional key=value syntax.
	DynamicArgs []string
	// contains filtered or unexported fields
}

ActionOptions holds configuration for the run action command.

func (*ActionOptions) Run added in v0.8.0

func (o *ActionOptions) Run(ctx context.Context) error

Run executes the selected actions from the solution.

type ActionProgressCallback

type ActionProgressCallback struct {
	// contains filtered or unexported fields
}

ActionProgressCallback implements action.ProgressCallback for CLI output. Action banners are written to stderr by default (like go-task/make) and are suppressed only by --quiet. Use --verbose for additional debug detail.

func NewActionProgressCallback

func NewActionProgressCallback(w *writer.Writer) *ActionProgressCallback

NewActionProgressCallback creates a new action progress callback.

func (*ActionProgressCallback) OnActionCancelled

func (a *ActionProgressCallback) OnActionCancelled(actionName string)

func (*ActionProgressCallback) OnActionComplete

func (a *ActionProgressCallback) OnActionComplete(actionName string, _ any)

func (*ActionProgressCallback) OnActionFailed

func (a *ActionProgressCallback) OnActionFailed(actionName string, err error)

func (*ActionProgressCallback) OnActionSkipped

func (a *ActionProgressCallback) OnActionSkipped(actionName, reason string)

func (*ActionProgressCallback) OnActionStart

func (a *ActionProgressCallback) OnActionStart(actionName, description string)

func (*ActionProgressCallback) OnActionTimeout

func (a *ActionProgressCallback) OnActionTimeout(actionName string, _ time.Duration)

func (*ActionProgressCallback) OnFinallyComplete

func (a *ActionProgressCallback) OnFinallyComplete()

func (*ActionProgressCallback) OnFinallyStart

func (a *ActionProgressCallback) OnFinallyStart()

func (*ActionProgressCallback) OnForEachProgress

func (a *ActionProgressCallback) OnForEachProgress(actionName string, completed, total int)

func (*ActionProgressCallback) OnPhaseComplete

func (a *ActionProgressCallback) OnPhaseComplete(_ int)

func (*ActionProgressCallback) OnPhaseStart

func (a *ActionProgressCallback) OnPhaseStart(_ int, _ []string)

func (*ActionProgressCallback) OnRetryAttempt

func (a *ActionProgressCallback) OnRetryAttempt(actionName string, attempt, maxAttempts int, err error)

type ProgressCallback

type ProgressCallback struct {
	// contains filtered or unexported fields
}

ProgressCallback provides a callback interface that can be used with the executor. This allows the progress reporter to be notified of execution events.

func NewProgressCallback

func NewProgressCallback(reporter *ProgressReporter) *ProgressCallback

NewProgressCallback creates a new progress callback wrapping the given reporter.

func (*ProgressCallback) OnPhaseStart

func (c *ProgressCallback) OnPhaseStart(phaseNum int, resolverNames []string)

OnPhaseStart is called when a new execution phase begins.

func (*ProgressCallback) OnResolverComplete

func (c *ProgressCallback) OnResolverComplete(resolverName string, elapsed time.Duration)

OnResolverComplete is called when a resolver completes successfully.

func (*ProgressCallback) OnResolverFailed

func (c *ProgressCallback) OnResolverFailed(resolverName string, err error)

OnResolverFailed is called when a resolver fails.

func (*ProgressCallback) OnResolverSkipped

func (c *ProgressCallback) OnResolverSkipped(resolverName string)

OnResolverSkipped is called when a resolver is skipped.

type ProgressReporter

type ProgressReporter struct {
	// contains filtered or unexported fields
}

ProgressReporter outputs execution progress using mpb. It provides visual feedback during resolver execution by displaying progress bars for each resolver in the current phase.

barElapsed and barFailed use sync.Map for lock-free reads inside mpb decorator callbacks, avoiding lock-ordering deadlocks with p.mu.

func NewProgressReporter

func NewProgressReporter(writer io.Writer, total int) *ProgressReporter

NewProgressReporter creates a new progress reporter writing to the given output. The total parameter indicates the total number of resolvers to be executed.

func (*ProgressReporter) Complete

func (p *ProgressReporter) Complete(resolverName string, elapsed time.Duration)

Complete marks a resolver as successfully completed. elapsed is the pure execution time measured by the caller.

func (*ProgressReporter) Failed

func (p *ProgressReporter) Failed(resolverName string, _ error)

Failed marks a resolver as failed with the given error.

func (*ProgressReporter) Skipped

func (p *ProgressReporter) Skipped(resolverName string)

Skipped marks a resolver as skipped (e.g., due to when condition).

func (*ProgressReporter) StartPhase

func (p *ProgressReporter) StartPhase(phaseNum int, resolverNames []string)

func (*ProgressReporter) TotalDuration

func (p *ProgressReporter) TotalDuration() time.Duration

TotalDuration returns the elapsed time since the reporter was created.

func (*ProgressReporter) Wait

func (p *ProgressReporter) Wait() time.Duration

Wait waits for all progress bars to complete and returns the total duration.

type ProviderOptions added in v0.2.0

type ProviderOptions struct {
	BinaryName string
	IOStreams  *terminal.IOStreams
	CliParams  *settings.Run

	// kvx output integration
	cmdflags.KvxOutputFlags

	// ProviderName is the name of the provider to execute (positional arg).
	ProviderName string

	// PluginVersion is the version to pin the plugin provider to.
	// Set via --plugin-version flag or name@version positional syntax.
	PluginVersion string

	// InputParams are the provider input parameters (--input key=value or --input @file.yaml).
	InputParams []string

	// DynamicArgs are provider inputs from positional or dynamic-flag syntax
	// (e.g. key=value or --key=value, captured after the provider name).
	DynamicArgs []string

	// Capability specifies which capability to execute.
	// Defaults to the first capability declared by the provider.
	Capability string

	// DryRun shows what would be executed without running the provider.
	DryRun bool

	// PluginDirs are directories to scan for plugin providers.
	PluginDirs []string

	// ShowMetrics shows provider execution metrics after completion.
	ShowMetrics bool

	// Redact redacts sensitive fields in the output.
	Redact bool

	// OutputDir is the target directory for action file operations.
	// When set and capability is action, providers resolve relative paths
	// against this directory instead of CWD.
	OutputDir string

	// OnConflict is the default conflict strategy for file writes.
	OnConflict string

	// Backup enables .bak backup creation before mutating existing files.
	Backup bool
}

ProviderOptions holds configuration for the run provider command

func (*ProviderOptions) Run added in v0.2.0

func (o *ProviderOptions) Run(ctx context.Context) error

Run executes a single provider directly

type ResolverExecutionConfig added in v0.5.0

type ResolverExecutionConfig = execute.ResolverExecutionConfig

Type aliases re-exporting from pkg/solution/execute for backward compatibility. Callers that import this package continue to work without modification.

func ResolverExecutionConfigFromContext added in v0.5.0

func ResolverExecutionConfigFromContext(ctx context.Context) ResolverExecutionConfig

ResolverExecutionConfigFromContext delegates to pkg/solution/execute.ResolverExecutionConfigFromContext.

type ResolverExecutionResult added in v0.5.0

type ResolverExecutionResult = execute.ResolverExecutionResult

Type aliases re-exporting from pkg/solution/execute for backward compatibility. Callers that import this package continue to work without modification.

type ResolverOptions added in v0.2.0

type ResolverOptions struct {
	BinaryName string

	// Names is the list of resolver names to execute (positional args).
	// If empty, all resolvers are executed.
	Names []string

	// Actions scopes resolver output to one or more actions by name.
	// When set, resolver names are extracted from each action's inputs
	// and the resolver execution is filtered to only those resolvers
	// (plus their transitive dependencies). Multiple values are unioned.
	Actions []string

	// SkipTransform skips the transform and validation phases,
	// returning raw resolved values.
	SkipTransform bool

	// Graph renders the resolver dependency graph instead of executing.
	Graph bool

	// GraphFormat controls the graph rendering format (ascii, dot, mermaid, json).
	GraphFormat string

	// Snapshot saves an execution snapshot to a file instead of normal output.
	Snapshot bool

	// SnapshotFile is the path to write the snapshot file.
	SnapshotFile string

	// Redact redacts sensitive values in the snapshot.
	Redact bool

	// ShowExecution includes the __execution metadata in output.
	ShowExecution bool

	// FailOnValidation makes the command exit with a non-zero status when any
	// resolver fails validation. By default, validation failures are reported as
	// non-fatal diagnostics (values are still shown) and the command exits 0.
	FailOnValidation bool

	// LintAfterValidate, when true, runs lint on the solution after resolver
	// validation passes. It is set by 'validate resolver' so that command acts
	// as a full gate (resolver validation + lint). 'run resolver' leaves it
	// false.
	LintAfterValidate bool

	// DynamicArgs are resolver parameters from positional key=value syntax
	// (e.g. env=prod region=us-east-1, captured from positional args containing '=').
	DynamicArgs []string
	// contains filtered or unexported fields
}

ResolverOptions holds configuration for the run resolver command

func (*ResolverOptions) Run added in v0.2.0

func (o *ResolverOptions) Run(ctx context.Context) error

Run executes the resolver-only flow

type SolutionOptions

type SolutionOptions struct {
	BinaryName string

	// Action execution options
	ActionTimeout        time.Duration
	MaxActionConcurrency int
	DryRun               bool

	// Verbose enables additional detail in output. In dry-run mode, includes
	// materialized inputs. In normal execution, shows condition-based skips.
	Verbose bool

	// ShowExecution enables __execution metadata in output
	ShowExecution bool

	// OnConflict is the default conflict strategy for file writes.
	// When set, it is injected into the execution context so file providers
	// use it as their default instead of the built-in "error".
	OnConflict string

	// Force overrides --on-conflict to "skip-unchanged", allowing re-runs of
	// solutions that produce identical files without errors.
	Force bool

	// SkipFingerprint disables fingerprint-based up-to-date checks.
	// When true, all actions execute regardless of whether sources have changed.
	SkipFingerprint bool

	// Backup enables .bak backup creation before mutating existing files.
	Backup bool

	// ActionNames is the list of action names to execute selectively.
	// When set, only the specified actions and their transitive dependsOn
	// dependencies are executed. Finally actions always run.
	ActionNames []string
	// contains filtered or unexported fields
}

SolutionOptions holds configuration for the run solution command

func (*SolutionOptions) Run

func (o *SolutionOptions) Run(ctx context.Context) error

Run executes the solution

type SolutionValidationResult added in v0.5.0

type SolutionValidationResult = execute.SolutionValidationResult

Type aliases re-exporting from pkg/solution/execute for backward compatibility. Callers that import this package continue to work without modification.

func ValidateSolution added in v0.5.0

func ValidateSolution(ctx context.Context, sol *solution.Solution, reg *provider.Registry) *SolutionValidationResult

ValidateSolution delegates to pkg/solution/execute.ValidateSolution.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL