stages

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2025 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadStages

func LoadStages(base map[string]schema.StageConfig, paths ...string) map[string]schema.StageConfig

LoadStages loads stage configurations from the specified paths and merges them with the base configuration. It processes dependencies and ensures the correct order of stages.

func NewStageConfig

func NewStageConfig(id string) schema.StageConfig

NewStageConfig creates a new StageConfig with default values for the specified stage ID.

func NewStageConfigPath

func NewStageConfigPath(path string, dir fs.DirEntry) schema.StageConfig

NewStageConfigPath creates a StageConfig by extracting information from the directory name and optionally loading additional configuration from a `stage.yaml` file.

Types

type CheckOpts

type CheckOpts struct {
	OnStart    func(cr CheckResult)        // Callback invoked when a check starts.
	OnComplete func(cr CheckResult)        // Callback invoked when a check completes.
	OnRetry    func(cr CheckResult, n int) // Callback invoked when a check is retried.
}

CheckOpts contains options for running stage checks.

type CheckResult

type CheckResult struct {
	Id    string // The unique identifier of the check.
	Type  string // The type of the check.
	Stage string // The stage associated with the check.
	Event string // The event associated with the check.
	Error error  // Any error encountered during the check.
}

CheckResult represents the result of a stage check.

func RunChecks

func RunChecks(ctx context.Context, cfg schema.QuartzConfig, stage string, event string, checks []StageCheck, opts *CheckOpts) ([]CheckResult, error)

RunChecks executes the specified stage checks and handles retries based on the retry configuration. Returns the results of the checks and any errors encountered.

func RunPostChecks

func RunPostChecks(ctx context.Context, cfg schema.QuartzConfig, providerFactory provider.ProviderFactory, stage string, event string, opts *CheckOpts) ([]CheckResult, error)

RunPostChecks executes post-event checks for the specified stage and event. Returns the results of the checks and any errors encountered.

func RunPreChecks

func RunPreChecks(ctx context.Context, cfg schema.QuartzConfig, providerFactory provider.ProviderFactory, stage string, event string, opts *CheckOpts) ([]CheckResult, error)

RunPreChecks executes pre-event checks for the specified stage and event. Returns the results of the checks and any errors encountered.

type HttpStageCheck

type HttpStageCheck schema.StageChecksHttpConfig

HttpStageCheck represents an HTTP-based stage check.

func (HttpStageCheck) Id

func (c HttpStageCheck) Id() string

Id returns the unique identifier of the HTTP stage check. If a URL is provided, it is used as the identifier; otherwise, the path is used.

func (HttpStageCheck) RetryOpts

RetryOpts returns the retry configuration for the HTTP stage check. It includes the retry limit and wait time between retries.

func (HttpStageCheck) Run

Run executes the HTTP stage check by sending a GET request to the specified URL. It validates the response status code and content based on the check configuration.

func (HttpStageCheck) Type

func (c HttpStageCheck) Type() string

Type returns the type of the stage check, which is "http".

type KubernetesStageCheck

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

KubernetesStageCheck represents a Kubernetes-based stage check.

func NewKubernetesStageCheck

func NewKubernetesStageCheck(src schema.StageChecksKubernetesConfig, providerFactory provider.ProviderFactory) KubernetesStageCheck

NewKubernetesStageCheck creates a new KubernetesStageCheck instance with the specified configuration and provider factory.

func (KubernetesStageCheck) Id

Id returns the unique identifier of the Kubernetes stage check. The identifier includes the kind, name, and namespace of the resource being checked.

func (KubernetesStageCheck) RetryOpts

RetryOpts returns the retry configuration for the Kubernetes stage check. By default, it allows only one attempt with no wait time between retries.

func (KubernetesStageCheck) Run

Run executes the Kubernetes stage check. It performs operations such as restarting resources, waiting for conditions, and validating resource states.

func (KubernetesStageCheck) Type

func (c KubernetesStageCheck) Type() string

Type returns the type of the stage check, which is "kubernetes".

type StageCheck

type StageCheck interface {
	// Run executes the stage check and returns an error if the check fails.
	Run(ctx context.Context, cfg schema.QuartzConfig) error
	// Id returns the unique identifier of the stage check.
	Id() string
	// Type returns the type of the stage check.
	Type() string
	// RetryOpts returns the retry configuration for the stage check.
	RetryOpts() schema.StageChecksRetryConfig
}

StageCheck defines the interface for stage checks.

type StageCheckRetryOpts

type StageCheckRetryOpts struct {
	Max            int // The maximum number of retries.
	BackoffSeconds int // The backoff time in seconds between retries.
}

StageCheckRetryOpts defines retry options for stage checks.

type StateStageCheck

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

StateStageCheck represents a state-based stage check.

func NewStateStageCheck

func NewStateStageCheck(src schema.StageChecksStateConfig, providerFactory provider.ProviderFactory) StateStageCheck

NewStateStageCheck creates a new StateStageCheck instance with the specified configuration and provider factory.

func (StateStageCheck) Id

func (c StateStageCheck) Id() string

Id returns the unique identifier of the state stage check. The identifier includes the key and expected value being checked.

func (StateStageCheck) RetryOpts

RetryOpts returns the retry configuration for the state stage check. It includes the retry limit and wait time between retries.

func (StateStageCheck) Run

Run executes the state stage check by validating the state stored in a Kubernetes ConfigMap. It ensures the specified key exists and matches the expected value.

func (StateStageCheck) Type

func (c StateStageCheck) Type() string

Type returns the type of the stage check, which is "state".

Jump to

Keyboard shortcuts

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