promotion

package
v1.9.3 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2026 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultStepRunnerRegistry = MustNewStepRunnerRegistry()
View Source
var ReservedStepAliasRegex = regexp.MustCompile(`^(step|task)-\d+$`)

ReservedStepAliasRegex is a regular expression that matches step aliases that are reserved for internal use.

Functions

func ConfigToStruct

func ConfigToStruct[T any](c Config) (T, error)

ConfigToStruct converts a Config to a (typed) configuration struct.

func DefaultExprDataCacheFn

func DefaultExprDataCacheFn() *gocache.Cache

DefaultExprDataCacheFn returns a new gocache.Cache instance with default expiration and cleanup intervals. This is used as the default ExprDataCacheFn for the Engine.

func DetermineFinalPhase added in v1.8.8

func DetermineFinalPhase(
	steps []Step,
	stepExecMetas kargoapi.StepExecutionMetadataList,
) (kargoapi.PromotionPhase, string)

DetermineFinalPhase determines the final PromotionPhase based on the statuses of individual steps. It takes into account the ContinueOnError flag for each step to decide whether a step's failure should impact the overall PromotionPhase.

It should not be used for determining the phase of an ongoing promotion (which would always have the phase "Running"). Instead, it is intended for use after all steps have completed to determine the final phase of the promotion.

func IsTerminal

func IsTerminal(err error) bool

IsTerminal returns true if the error is a terminal error or wraps one and false otherwise.

Types

type Config

type Config map[string]any

Config is an opaque map of configuration values for a Step. The keys and values are arbitrary and implementations of StepRunner are responsible for interpreting them.

func (Config) DeepCopy

func (c Config) DeepCopy() Config

DeepCopy returns a deep copy of the configuration.

func (Config) ToJSON

func (c Config) ToJSON() []byte

ToJSON marshals the configuration to JSON.

type Context

type Context struct {
	// UIBaseURL may be used to construct deeper URLs for interacting with the
	// Kargo UI.
	UIBaseURL string
	// WorkDir is the working directory to use for the Promotion.
	WorkDir string
	// Project is the Project that the Promotion is associated with.
	Project string
	// Stage is the Stage that the Promotion is targeting.
	Stage string
	// Promotion is the name of the Promotion.
	Promotion string
	// FreightRequests is the list of Freight from various origins that is
	// requested by the Stage targeted by the Promotion.
	//
	// This information is sometimes useful to Steps that reference a particular
	// artifact. When explicit information about the artifact's origin is absent,
	// Steps may need to examine FreightRequests.
	// This examination helps determine whether any ambiguity exists regarding
	// the artifact's origin. If ambiguity is found, a user may need to resolve
	// it.
	FreightRequests []kargoapi.FreightRequest
	// Freight is the collection of all Freight referenced by the Promotion. This
	// collection contains both the Freight that is actively being promoted and
	// any Freight that has been inherited from the target Stage's current
	// state.
	Freight kargoapi.FreightCollection
	// TargetFreightRef is the actual Freight that triggered this Promotion.
	TargetFreightRef kargoapi.FreightReference
	// StartFromStep is the index of the step from which the promotion should
	// begin execution.
	StartFromStep int64
	// StepExecutionMetadata tracks metadata pertaining to the execution
	// of individual promotion steps.
	StepExecutionMetadata kargoapi.StepExecutionMetadataList
	// State is the current state of the promotion process.
	State State
	// Vars is a list of variable definitions that can be used by the
	// Steps.
	Vars []kargoapi.ExpressionVariable
	// Actor is the name of the actor triggering the Promotion.
	Actor string
	// contains filtered or unexported fields
}

Context is the context of a user-defined promotion process that is executed by the Engine.

func NewContext added in v1.8.8

func NewContext(
	promo *kargoapi.Promotion,
	stage *kargoapi.Stage,
	opts ...ContextOption,
) Context

NewContext creates a new Context for a user-defined promotion process executed by the Engine. It initializes the Context with the data from the provided Promotion and Stage, applying any additional options provided.

func (*Context) DeepCopy

func (c *Context) DeepCopy() Context

DeepCopy creates a deep copy of the Context. It can be used to ensure that modifications to the Context do not affect the original Context.

func (*Context) GetCurrentStep added in v1.8.8

func (c *Context) GetCurrentStep() *StepMetadata

GetCurrentStep retrieves the StepMetadata for the current step being executed. If no current step is set, it returns nil.

func (*Context) GetCurrentStepIndex added in v1.8.8

func (c *Context) GetCurrentStepIndex() int64

GetCurrentStepIndex retrieves the index of the current step being executed. It derives this from the length of StepExecutionMetadata, which is built incrementally as steps are encountered.

func (*Context) GetStepExecutionMetadata added in v1.8.8

func (c *Context) GetStepExecutionMetadata(step Step) *kargoapi.StepExecutionMetadata

GetStepExecutionMetadata retrieves the StepExecutionMetadata for a given Step. If metadata for the Step does not already exist, it creates a new StepExecutionMetadata entry with the Step's alias and ContinueOnError property, and returns it.

func (*Context) SetCurrentStep added in v1.8.8

func (c *Context) SetCurrentStep(step Step) *StepMetadata

SetCurrentStep sets the current step to the provided Step and returns a StepMetadata that can be used to update the execution metadata of the step.

type ContextOption added in v1.8.8

type ContextOption func(*Context)

ContextOption is a function that configures a Context.

func WithActor added in v1.8.8

func WithActor(actor string) ContextOption

WithActor sets the Actor of the Context.

func WithUIBaseURL added in v1.8.8

func WithUIBaseURL(url string) ContextOption

WithUIBaseURL sets the UIBaseURL of the Context.

func WithWorkDir added in v1.8.8

func WithWorkDir(dir string) ContextOption

WithWorkDir sets the WorkDir of the Context.

type Engine

type Engine interface {
	// Promote executes the specified sequence of Steps and returns a Result
	// that aggregates the results of all steps.
	Promote(context.Context, Context, []Step) (Result, error)
}

Engine is an interface for executing a sequence of promotion steps.

type ExprDataCacheFn

type ExprDataCacheFn func() *gocache.Cache

ExprDataCacheFn is a function that returns a new cache to use in expression functions that consult the Kubernetes API.

A new cache is created for each step execution, so that the cache is shared between all expression functions that are executed in the same step. This is important for performance, as our Kubernetes API client does not cache Secrets and ConfigMaps, but also for correctness, as the data may change between calls.

It is allowed for the cache to be nil, in which case the expression functions will not cache their results.

type ExprEnvOption added in v1.8.8

type ExprEnvOption func(map[string]any)

ExprEnvOption is a functional option for customizing the expression language environment built by the StepEvaluator for a Step.

func ExprEnvWithOutputs added in v1.8.8

func ExprEnvWithOutputs(outputs State) ExprEnvOption

ExprEnvWithOutputs returns a ExprEnvOption that adds the provided outputs to the expression language environment of the Step.

func ExprEnvWithStepMetas added in v1.8.8

func ExprEnvWithStepMetas(promoCtx Context) ExprEnvOption

ExprEnvWithStepMetas returns a ExprEnvOption that adds StepExecutionMetadata indexed by alias to the expression language environment of the Step.

func ExprEnvWithTaskOutputs added in v1.8.8

func ExprEnvWithTaskOutputs(alias string, outputs State) ExprEnvOption

ExprEnvWithTaskOutputs returns a ExprEnvOption that adds the provided task outputs to the expression language environment of the Step.

func ExprEnvWithVars added in v1.8.8

func ExprEnvWithVars(vars map[string]any) ExprEnvOption

ExprEnvWithVars returns a ExprEnvOption that adds the provided vars to the expression language environment of the Step.

type LocalEngine added in v1.8.8

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

LocalEngine is an implementation of the Engine interface that uses built-in StepRunners locally.

func NewLocalEngine added in v1.8.8

func NewLocalEngine(
	kargoClient client.Client,
	argocdClient client.Client,
	credsDB credentials.Database,
	cacheFunc ExprDataCacheFn,
) *LocalEngine

NewLocalEngine returns an implementation of the Engine interface that uses built-in StepRunners locally.

func (*LocalEngine) Promote added in v1.8.8

func (e *LocalEngine) Promote(
	ctx context.Context,
	promoCtx Context,
	steps []Step,
) (_ Result, err error)

Promote implements the Engine interface.

type LocalOrchestrator added in v1.8.8

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

LocalOrchestrator is an implementation of the Orchestrator interface that executes steps locally using the provided StepExecutor and StepRunner registry.

func NewLocalOrchestrator added in v1.8.8

func NewLocalOrchestrator(
	registry StepRunnerRegistry,
	kargoClient, argoCDClient client.Client,
	credsDB credentials.Database,
	cacheFunc ExprDataCacheFn,
) *LocalOrchestrator

NewLocalOrchestrator creates a new LocalOrchestrator instance with the provided client, step runner registry, and cache function.

func (*LocalOrchestrator) ExecuteSteps added in v1.8.8

func (o *LocalOrchestrator) ExecuteSteps(
	ctx context.Context,
	promoCtx Context,
	steps []Step,
) (Result, error)

ExecuteSteps executes the provided steps in the context of the given Promotion context. It iterates through the steps, evaluates their "if" conditions, and executes them if they are not skipped. It also handles the execution metadata for each step, including start and finish times, statuses, and error handling. The method returns a Result that contains the final status of the Promotion after executing all steps, including any health checks that were performed during the execution.

type LocalStepExecutor added in v1.8.8

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

LocalStepExecutor is a concrete implementation of StepExecutor that executes steps locally using step runners registered in a registry.

func NewLocalStepExecutor added in v1.8.8

func NewLocalStepExecutor(
	registry StepRunnerRegistry,
	kargoClient, argoCDClient client.Client,
	credsDB credentials.Database,
) *LocalStepExecutor

NewLocalStepExecutor creates a new LocalStepExecutor with the provided step runner registry. This executor will use the registered runners to execute steps in the promotion process.

func (*LocalStepExecutor) ExecuteStep added in v1.8.8

func (e *LocalStepExecutor) ExecuteStep(
	ctx context.Context,
	req StepExecutionRequest,
) (result StepResult, err error)

ExecuteStep executes a single promotion Step using the registered step runner for the Step's kind. It handles any errors that occur during execution and returns a StepResult indicating the outcome of the step execution.

type MockEngine

type MockEngine struct {
	PromoteFn func(context.Context, Context, []Step) (Result, error)
}

MockEngine is a mock implementation of the Engine interface that can be used to facilitate unit testing.

func (*MockEngine) Promote

func (m *MockEngine) Promote(
	ctx context.Context,
	promoCtx Context,
	steps []Step,
) (Result, error)

Promote implements the Engine interface.

type MockStepRunner

type MockStepRunner struct {
	// RunFunc is the function that this MockStepRunner should call when Run is
	// called. If set, this function will be called instead of returning RunResult
	// and RunErr.
	RunFunc func(context.Context, *StepContext) (StepResult, error)
	// RunResult is the result that this MockStepRunner should return when Run is
	// called.
	RunResult StepResult
	// RunErr is the error that this MockStepRunner should return when Run is
	// called.
	RunErr error
}

MockStepRunner is a mock implementation of the StepRunner interface, which can be used for testing.

func (*MockStepRunner) Run

func (m *MockStepRunner) Run(
	ctx context.Context,
	stepCtx *StepContext,
) (StepResult, error)

Run implements the StepRunner interface.

type Orchestrator added in v1.8.8

type Orchestrator interface {
	// ExecuteSteps executes the provided steps in the context of the given
	// Promotion Context. It returns a Result that contains the status of the
	// Promotion after executing the steps, including any health checks that
	// were performed during the execution.
	ExecuteSteps(ctx context.Context, promoCtx Context, steps []Step) (Result, error)
}

Orchestrator is an interface that defines the methods required to execute a series of steps in a Promotion. It is responsible for orchestrating the execution of steps, handling their results, and managing the state of the Promotion as it progresses through the steps.

type Result

type Result struct {
	// Status is the high-level outcome of the user-defined promotion executed by
	// the Engine.
	Status kargoapi.PromotionPhase
	// Message is an optional message that provides additional context about the
	// outcome of the user-defined promotion executed by the Engine.
	Message string
	// HealthChecks collects health.Criteria returned from the execution of
	// individual Steps by their corresponding StepRunners. These criteria can
	// later be used as input to health.Checkers.
	HealthChecks []health.Criteria
	// If the promotion process remains in-progress, perhaps waiting for a change
	// in some external state, the value of this field will indicate where to
	// resume the process in the next reconciliation.
	CurrentStep int64
	// StepExecutionMetadata tracks metadata pertaining to the execution
	// of individual promotion steps.
	StepExecutionMetadata kargoapi.StepExecutionMetadataList
	// State is the current state of the promotion process.
	State State
	// RetryAfter is an optional, SUGGESTED duration after which a Promotion
	// reporting itself to be in a Running status should be retried. Note: This is
	// unrelated to retrying upon non-terminal failures.
	RetryAfter *time.Duration
}

Result is the result of a user-defined promotion process executed by the Engine. It aggregates the status and output of the individual StepResults returned by the StepRunner executing each Step.

type State

type State map[string]any

State is a type that represents state shared by Steps in a user-defined promotion process. It is not safe for concurrent use at present, as we expect Steps to be executed sequentially.

func (*State) DeepCopy

func (s *State) DeepCopy() State

DeepCopy returns a deep copy of the state.

func (State) Get

func (s State) Get(key string) (any, bool)

Get retrieves a value from the shared state.

func (State) Set

func (s State) Set(key string, value any)

Set stores a value in the shared state.

func (State) ToJSON

func (s State) ToJSON() []byte

ToJSON marshals the State to JSON.

type Step

type Step struct {
	// Kind identifies a registered StepRunner that implements the logic for this
	// step of the user-defined promotion process.
	Kind string
	// Alias is an optional identifier for this step of the use-defined promotion
	// process, which must be unique to the process. Output from execution of the
	// step will be keyed to this alias by the Engine and made accessible to
	// subsequent steps.
	Alias string
	// If is an optional expression that, if present, must evaluate to a boolean
	// value. If the expression evaluates to false, the step will be skipped.
	// If the expression does not evaluate to a boolean value, the step will
	// fail.
	If string
	// ContinueOnError is a boolean value that, if set to true, will cause the
	// Promotion to continue executing the next step even if this step fails. It
	// also will not permit this failure to impact the overall status of the
	// Promotion.
	ContinueOnError bool
	// Retry is the retry configuration for the Step.
	Retry *kargoapi.PromotionStepRetry
	// Vars is a list of variables definitions that can be used by the
	// Step.
	Vars []kargoapi.ExpressionVariable
	// Config is an opaque JSON to be passed to the StepRunner executing this
	// step.
	Config []byte
}

Step describes a single step in a user-defined promotion process. Steps are executed in sequence by the Engine, which delegates of each to a StepRunner.

func NewSteps added in v1.8.8

func NewSteps(promo *kargoapi.Promotion) []Step

NewSteps creates a slice of Steps from the provided Promotion. Each Step in the slice corresponds to a step defined in the Promotion's spec.

type StepContext

type StepContext struct {
	// UIBaseURL may be used to construct deeper URLs for interacting with the
	// Kargo UI.
	UIBaseURL string
	// WorkDir is the root directory for the execution of a step.
	WorkDir string
	// SharedState is the state shared between steps.
	SharedState State
	// Alias is the alias of the step that is currently being executed.
	Alias string
	// Config is the configuration of the step that is currently being
	// executed.
	Config Config
	// Project is the Project that the Promotion is associated with.
	Project string
	// Stage is the Stage that the Promotion is targeting.
	Stage string
	// Promotion is the name of the Promotion.
	Promotion string
	// PromotionActor is the name of the actor triggering the Promotion.
	PromotionActor string
	// FreightRequests is the list of Freight from various origins that is
	// requested by the Stage targeted by the Promotion. This information is
	// sometimes useful to Step that reference a particular artifact and, in the
	// absence of any explicit information about the origin of that artifact, may
	// need to examine FreightRequests to determine whether there exists any
	// ambiguity as to its origin, which a user may then need to resolve.
	//
	// TODO: krancour: Longer term, if we can standardize the way that Steps
	// express the artifacts they need to work with, we can make the Engine
	// responsible for finding them and furnishing them directly to each
	// StepRunner.
	FreightRequests []kargoapi.FreightRequest
	// Freight is the collection of all Freight referenced by the Promotion. This
	// collection contains both the Freight that is actively being promoted as
	// well as any Freight that has been inherited from the target Stage's current
	// state.
	//
	// TODO: krancour: Longer term, if we can standardize the way that Steps
	// express the artifacts they need to work with, we can make the Engine
	// responsible for finding them and furnishing them directly to each
	// StepRunner.
	Freight kargoapi.FreightCollection
	// TargetFreightRef is the actual Freight that triggered this Promotion.
	TargetFreightRef kargoapi.FreightReference
}

StepContext is a type that represents the context in which a single promotion step is executed by a StepRunner.

type StepEvaluator added in v1.8.8

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

StepEvaluator handles the evaluation and processing of Promotion steps, including conditional logic, configuration templating, and context building. It centralizes all complex expression evaluation logic that determines how steps should be executed based on the current state of the Promotion.

The processor maintains a shared cache to improve performance when multiple expressions within the same step access the same data, such as Secrets or ConfigMaps.

func NewStepEvaluator added in v1.8.8

func NewStepEvaluator(cl client.Client, cache *gocache.Cache) *StepEvaluator

NewStepEvaluator creates a new StepEvaluator instance with the provided Kubernetes client and cache. The cache is optional, and can be used to store Kubernetes objects that are frequently accessed by the expression evaluation logic, such as Secrets and ConfigMaps, to avoid unnecessary API calls and improve performance.

func (*StepEvaluator) BuildExprEnv added in v1.8.8

func (p *StepEvaluator) BuildExprEnv(promoCtx Context, opts ...ExprEnvOption) map[string]any

BuildExprEnv builds an environment map for evaluating expressions in Promotion steps. The environment includes context information, such as the Project, Promotion, Stage, and target Freight reference.

The environment can be extended with additional options provided via the ExprEnvOption functional options. These options can be used to add variables or modify the expression language environment.

func (*StepEvaluator) BuildStepContext added in v1.8.8

func (p *StepEvaluator) BuildStepContext(
	ctx context.Context,
	promoCtx Context,
	step Step,
) (*StepContext, error)

BuildStepContext builds a StepContext for the given Step in the context of the provided Promotion context. The StepContext contains all the necessary information needed to execute the Step, including the evaluated configuration, the shared state, and the alias of the Step.

func (*StepEvaluator) Config added in v1.8.8

func (p *StepEvaluator) Config(ctx context.Context, promoCtx Context, step Step) (Config, error)

Config evaluates the configuration defined in the Step, returning a map of configuration keys to their evaluated values. The configuration is evaluated in the context of the Context and Step, allowing for dynamic configuration based on the current state of the Promotion.

func (*StepEvaluator) ShouldSkip added in v1.8.8

func (p *StepEvaluator) ShouldSkip(ctx context.Context, promoCtx Context, step Step) (bool, error)

ShouldSkip determines whether a Step should be skipped based on the "if" condition defined in the Step. If the "if" condition evaluates to false, the Step is skipped. If the "if" condition is not defined, the Step is skipped if any of the previous Steps have failed or errored and are not skipped otherwise.

func (*StepEvaluator) Vars added in v1.8.8

func (p *StepEvaluator) Vars(ctx context.Context, promoCtx Context, step Step) (map[string]any, error)

Vars evaluates the variables defined in the Context and Step, returning a map of variable names to their evaluated values. The variables defined in the Context are evaluated first, followed by the variables defined in the Step.

The variables defined in the Context do not have access to the outputs of the Step, while the variables defined in the Step do have access to the outputs of any preceding Steps.

type StepExecutionRequest added in v1.8.8

type StepExecutionRequest struct {
	Context StepContext `json:"context"`
	Step    Step        `json:"step"`
}

StepExecutionRequest represents a request to execute a Step. It contains all the necessary Context and Step information required for executing the Step.

type StepExecutor added in v1.8.8

type StepExecutor interface {
	ExecuteStep(ctx context.Context, req StepExecutionRequest) (StepResult, error)
}

StepExecutor defines the interface for executing a single Step.

type StepMetadata added in v1.8.8

type StepMetadata kargoapi.StepExecutionMetadata

StepMetadata is a type that represents metadata about the execution of a single step in a user-defined promotion process. It is used to track the status, start and finish times, error counts, and other relevant information about the step's execution. This metadata is stored in the StepExecutionMetadata field of the Context and is used to provide detailed information about the execution of each step in the promotion process.

func (*StepMetadata) Error added in v1.8.8

func (m *StepMetadata) Error() *StepMetadata

Error increments the error count of the StepMetadata and returns the updated StepMetadata. This method is used to track the number of errors encountered during the execution of the step. It is typically called when the step fails or encounters an error condition.

func (*StepMetadata) Finished added in v1.8.8

func (m *StepMetadata) Finished() *StepMetadata

Finished sets the FinishedAt timestamp to the current time if it is not already set, indicating that the step has completed its execution. It returns the updated StepMetadata. This method is used to mark the end of the step's execution, indicating when the step finished processing.

func (*StepMetadata) Started added in v1.8.8

func (m *StepMetadata) Started() *StepMetadata

Started sets the StartedAt timestamp to the current time if it is not already set, and resets the error count to zero. It returns the updated StepMetadata. This method is used to mark the start of the step's execution, indicating when the step began processing.

func (*StepMetadata) WithMessage added in v1.8.8

func (m *StepMetadata) WithMessage(message string) *StepMetadata

WithMessage sets the message of the StepMetadata and returns the updated StepMetadata. This method is used to provide additional context or details about the step's execution, such as error messages or informational messages that may be useful for debugging or understanding the step's outcome.

func (*StepMetadata) WithMessagef added in v1.8.8

func (m *StepMetadata) WithMessagef(format string, a ...any) *StepMetadata

WithMessagef formats the message using the provided format string and arguments, sets it as the message of the StepMetadata, and returns the updated StepMetadata. This method is useful for constructing dynamic messages that include variable content, such as error details or step-specific information.

func (*StepMetadata) WithStatus added in v1.8.8

func (m *StepMetadata) WithStatus(status kargoapi.PromotionStepStatus) *StepMetadata

WithStatus sets the status of the StepMetadata and returns the updated StepMetadata. This method is used to update the status of the step during its execution, such as when it starts, finishes, or encounters an error.

type StepResult

type StepResult struct {
	// Status is the high-level outcome of a Step executed by a StepRunner.
	Status kargoapi.PromotionStepStatus
	// Message is an optional message that provides additional context about the
	// outcome of a Step executed by a StepRunner.
	Message string
	// Output is the opaque output of a Step executed by a StepRunner. The Engine
	// will update the shared state with this output, making it available to the
	// StepRunners executing subsequent Steps.
	Output map[string]any
	// HealthCheck identifies criteria for a health check process. This is
	// returned by some StepRunner upon successful execution of a Step. These
	// criteria can be used later as input to a health.Checker.
	HealthCheck *health.Criteria
	// RetryAfter is an optional, SUGGESTED duration after which a step reporting
	// itself to be in a Running status should be retried. Note: This is unrelated
	// to retrying upon non-terminal failures.
	RetryAfter *time.Duration
}

StepResult represents the results of a single Step of a user-defined promotion process executed by a StepRunner.

type StepRunner

type StepRunner interface {
	// Run executes an individual Step from a user-defined promotion process
	// using the provided StepContext. Implementations may indirectly modify
	// that context through the returned StepResult to allow StepRunners of
	// subsequent Steps to access the results of this execution.
	Run(context.Context, *StepContext) (StepResult, error)
}

StepRunner is an interface for components that implement the logic for execution of an individual Step in a user-defined promotion process.

type StepRunnerCapabilities

type StepRunnerCapabilities struct {
	KargoClient  client.Client
	ArgoCDClient client.Client
	CredsDB      credentials.Database
}

StepRunnerCapabilities is a bundle of any special dependencies that may be injected into StepRunner implementations to grant them specific capabilities they may otherwise lack.

type StepRunnerCapability

type StepRunnerCapability string

StepRunnerCapability is a type representing special capabilities that may be required by a StepRunner in order to execute a step successfully. The engine executing a StepRunner is responsible for injecting corresponding dependencies into it when invoking its factory function.

const (
	// StepCapabilityAccessArgoCD represents the capability of interacting with
	// an Argo CD control plane via a Kubernetes client.
	StepCapabilityAccessArgoCD StepRunnerCapability = "access-argocd"
	// StepCapabilityAccessControlPlane represents the capability of interacting
	// with the Kargo control plane via a Kubernetes client.
	StepCapabilityAccessControlPlane StepRunnerCapability = "access-control-plane"
	// StepCapabilityAccessCredentials represents the capability to obtain
	// repository credentials through a lookup by credential type and repository
	// URL.
	StepCapabilityAccessCredentials StepRunnerCapability = "access-credentials"
	// StepCapabilityTaskOutputPropagation represents the capability of a step,
	// when executed as part of a task, to propagate its output directly to the
	// Promotion's shared state, in addition to the task's own state.
	StepCapabilityTaskOutputPropagation StepRunnerCapability = "task-output-propagation"
)

type StepRunnerFactory added in v1.8.8

type StepRunnerFactory = func(StepRunnerCapabilities) StepRunner

type StepRunnerMetadata

type StepRunnerMetadata struct {
	// DefaultTimeout is the default soft maximum interval in which a StepRunner
	// that returns a Running status (which typically indicates it's waiting for
	// something to happen) may be retried.
	//
	// The maximum is a soft one because the check for whether the interval has
	// elapsed occurs AFTER the step has run. This effectively means a step may
	// run ONCE beyond the close of the interval.
	//
	// A value of 0 will cause the step to be retried indefinitely unless the
	// ErrorThreshold is reached.
	//
	// This default can be overridden by step-level configuration.
	DefaultTimeout time.Duration
	// DefaultErrorThreshold is the number of consecutive times the step must fail
	// (for any reason) before retries are abandoned and the entire Promotion is
	// marked as failed.
	//
	// If this field is set to a non-positive value, it will be changed to the
	// system-wide default of 1 at registration time.
	//
	// A value of 1 will cause the Promotion to be marked as failed after just
	// a single failure; i.e. no retries will be attempted.
	//
	// This default can be overridden by step-level configuration.
	DefaultErrorThreshold uint32
	// RequiredCapabilities is a list of constants representing special
	// capabilities required by the StepRunner in order to execute a step
	// successfully. The engine executing the StepRunner is responsible for
	// injecting necessary dependencies into the StepRunner when invoking its
	// factory function. By default, StepRunners are not granted any special
	// capabilities.
	RequiredCapabilities []StepRunnerCapability
}

StepRunnerMetadata contains metadata about a StepRunner.

type StepRunnerRegistry added in v1.8.8

func MustNewStepRunnerRegistry added in v1.8.8

func MustNewStepRunnerRegistry(
	registrations ...StepRunnerRegistration,
) StepRunnerRegistry

MustNewStepRunnerRegistry overrides the internalRegistry's MustRegister() method to call the implementation-specific Register() method.

type TerminalError

type TerminalError struct {
	Err error
}

TerminalError wraps another error to indicate to the step execution engine that the step that produced the error should not be retried.

func (*TerminalError) Error

func (e *TerminalError) Error() string

Error implements the error interface.

Directories

Path Synopsis
runner

Jump to

Keyboard shortcuts

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