Help us shape the future of Go! Take the 2026 Go Developer Survey

stages

package
v0.109.1 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2026 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotManagedByDocoCD = errors.New("stack is not managed by doco-cd")
	ErrDeploymentConflict = errors.New("another stack with the same name already exists and is not managed by this repository")
	ErrSkipDeployment     = errors.New("deployment skipped") // Special error to indicate deployment was skipped, not an actual failure/error
)

Functions

This section is empty.

Types

type CleanupStageData

type CleanupStageData struct {
	MetaData
}

CleanupStageData holds the configuration and data specific to the cleanup stage.

type DeployStageData

type DeployStageData struct {
	MetaData
}

DeployStageData holds the configuration and data specific to the deployment stage.

type DeploymentState

type DeploymentState struct {
	DeployedCommit string // previously-deployed commit SHA, carried to post-deploy for the changelog
	// contains filtered or unexported fields
}

DeploymentState holds the dynamic state information during the deployment process.

type DestroyStageData

type DestroyStageData struct {
	MetaData
}

type Docker

type Docker struct {
	Cmd            command.Cli
	DataMountPoint container.MountPoint
	Project        *types.Project
	SwarmMode      bool
}

Docker holds the Docker CLI and client instances along with the data mount point.

type InitStageData

type InitStageData struct {
	MetaData
}

InitStageData holds the configuration and data specific to the initialization stage.

type JobTrigger

type JobTrigger string
const (
	JobTriggerWebhook JobTrigger = "webhook"
	JobTriggerPoll    JobTrigger = "poll"
)

type MetaData

type MetaData struct {
	Name       StageName
	StartedAt  time.Time
	FinishedAt time.Time
}

func NewMetaData

func NewMetaData(name StageName) MetaData

type NotifyFailureFunc added in v0.82.0

type NotifyFailureFunc func(log *slog.Logger, err error, metadata notification.Metadata)

type PostDeployStageData

type PostDeployStageData struct {
	MetaData
}

PostDeployStageData holds the configuration and data specific to the post-deployment stage.

type PostDestroyStageData

type PostDestroyStageData struct {
	MetaData
}

type PreDeployStageData

type PreDeployStageData struct {
	MetaData
}

PreDeployStageData holds the configuration and data specific to the pre-deployment stage.

type RepositoryData

type RepositoryData struct {
	Source       types2.SourceType // Source backend used for this deployment (git or oci)
	SourceUrl    string            // Repository or OCI artifact URL (e.g., "https://github.com/user/my-repo.git" or "ghcr.io/org/repo:tag")
	Name         string            // Repository name (e.g., "user/my-repo")
	PathInternal string            // Path to the repository inside the container
	PathExternal string            // Path to the repository on the host machine
	Git          *git.Repository   // Git repository instance
	Revision     string            // Resolved immutable revision (commit SHA or digest)
	OCITrusted   bool              // True when the OCI artifact passed trust-policy verification before reconciliation/cleanup
}

RepositoryData holds information about the triggering repository.

type StageFunc

type StageFunc func(ctx context.Context, stageLog *slog.Logger) error

type StageManager

type StageManager struct {
	Stages            *Stages
	Log               *slog.Logger
	JobID             string            // Unique identifier for the job
	JobTrigger        JobTrigger        // Trigger type for the job (e.g., "webhook", "poll")
	NotifyFailureFunc NotifyFailureFunc // Function to call on failure
	AppConfig         *app.Config
	DeployConfig      *deploy.Config
	DeployState       *DeploymentState
	Docker            *Docker
	Payload           *webhook.ParsedPayload
	Repository        *RepositoryData
	SecretProvider    *secretprovider.SecretProvider
	Metadata          notification.Metadata // Notification metadata (may include reconciliation event info)
}

StageManager is the main structure that holds the logger and stage data.

func NewStageManager

func NewStageManager(jobID string, jobTrigger JobTrigger, log *slog.Logger,
	failNotifyFunc NotifyFailureFunc,
	repoData *RepositoryData, dockerData *Docker, payload *webhook.ParsedPayload,
	appConfig *app.Config, deployConfig *deploy.Config,
	secretProvider *secretprovider.SecretProvider,
	metadata notification.Metadata,
) *StageManager

NewStageManager creates and initializes a new StageManager instance for managing stages.ß.

func (*StageManager) GetCurrentCommitStatus added in v0.96.0

func (s *StageManager) GetCurrentCommitStatus(ctx context.Context) (commitstatus.Status, bool)

func (*StageManager) GetDeployStageOrder

func (s *StageManager) GetDeployStageOrder() StageOrder

GetDeployStageOrder returns the order of stages for the deployment process.

func (*StageManager) GetDestroyStageOrder

func (s *StageManager) GetDestroyStageOrder() StageOrder

GetDestroyStageOrder returns the order of stages for the destroy process.

func (*StageManager) GetStageMetaData

func (s *StageManager) GetStageMetaData(stageName StageName) (*MetaData, error)

GetStageMetaData retrieves the metadata for the specified stage.

func (*StageManager) NotifyDeploymentStarted added in v0.107.0

func (s *StageManager) NotifyDeploymentStarted() error

func (*StageManager) NotifyFailure

func (s *StageManager) NotifyFailure(notifyErr error)

NotifyFailure sends a failure notification using the provided NotifyFailureFunc.

func (*StageManager) PostCommitStatus added in v0.96.0

func (s *StageManager) PostCommitStatus(ctx context.Context, state commitstatus.State, description string)

PostCommitStatus posts a commit status to the source Git provider. It is a no-op when GIT_COMMIT_STATUS is disabled, when the source is OCI, or when no access token / commit SHA is available. Errors are logged as warnings so they never block a deployment.

func (*StageManager) RunCleanupStage

func (s *StageManager) RunCleanupStage(_ context.Context, _ *slog.Logger) error

func (*StageManager) RunDeployStage

func (s *StageManager) RunDeployStage(ctx context.Context, stageLog *slog.Logger) error

func (*StageManager) RunDestroyStage

func (s *StageManager) RunDestroyStage(ctx context.Context, stageLog *slog.Logger) error

func (*StageManager) RunInitStage

func (s *StageManager) RunInitStage(ctx context.Context, stageLog *slog.Logger) error

RunInitStage executes the initialization stage logic for the deployment process.

func (*StageManager) RunPostDeployStage

func (s *StageManager) RunPostDeployStage(_ context.Context, stageLog *slog.Logger) error

func (*StageManager) RunPostDestroyStage

func (s *StageManager) RunPostDestroyStage(_ context.Context, stageLog *slog.Logger) error

func (*StageManager) RunPreDeployStage

func (s *StageManager) RunPreDeployStage(ctx context.Context, stageLog *slog.Logger) error

func (*StageManager) RunStages

func (s *StageManager) RunStages(ctx context.Context) error

RunStages executes the stages in the defined order.

type StageName

type StageName string
const (
	StageInit        StageName = "init"
	StagePreDeploy   StageName = "pre-deploy"
	StageDestroy     StageName = "destroy"
	StageDeploy      StageName = "deploy"
	StagePostDeploy  StageName = "post-deploy"
	StagePostDestroy StageName = "post-destroy"
	StageCleanup     StageName = "cleanup"
)

type StageOrder

type StageOrder struct {
	Order []StageName             // The order of stages to be executed
	Funcs map[StageName]StageFunc // Mapping of stage names to their execution functions
}

StageOrder holds the ordered list of stage names and their corresponding functions.

type StageResult

type StageResult string

type StageStatus

type StageStatus string

type Stages

type Stages struct {
	Init        *InitStageData
	PreDeploy   *PreDeployStageData
	Deploy      *DeployStageData
	Destroy     *DestroyStageData
	PostDeploy  *PostDeployStageData
	PostDestroy *PostDestroyStageData
	Cleanup     *CleanupStageData
}

Stages holds the data for all stages in the deployment process.

Jump to

Keyboard shortcuts

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