stages

package
v0.72.2 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2026 License: Apache-2.0 Imports: 26 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 {
	ChangedFiles    []gitInternal.ChangedFile
	SecretsChanged  bool
	ResolvedSecrets secrettypes.ResolvedSecrets
}

DeploymentState holds the dynamic state information during the deployment process.

type DestroyStageData

type DestroyStageData struct {
	MetaData
}

type Docker

type Docker struct {
	Cmd            command.Cli
	Client         *client.Client
	DataMountPoint container.MountPoint
}

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 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 {
	CloneURL     config.HttpUrl  // Repository clone URL (e.g., "https://github.com/user/my-repo.git")
	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
}

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 func(err error, metadata notification.Metadata) // Function to call on failure
	AppConfig         *config.AppConfig
	DeployConfig      *config.DeployConfig
	DeployState       *DeploymentState
	Docker            *Docker
	Payload           *webhook.ParsedPayload
	Repository        *RepositoryData
	SecretProvider    *secretprovider.SecretProvider
}

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

func NewStageManager

func NewStageManager(jobID string, jobTrigger JobTrigger, log *slog.Logger,
	failNotifyFunc func(err error, metadata notification.Metadata),
	repoData *RepositoryData, dockerData *Docker, payload *webhook.ParsedPayload,
	appConfig *config.AppConfig, deployConfig *config.DeployConfig,
	secretProvider *secretprovider.SecretProvider,
) *StageManager

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

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) NotifyFailure

func (s *StageManager) NotifyFailure(notifyErr error)

NotifyFailure sends a failure notification using the provided NotifyFailureFunc.

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