Documentation ¶
Overview ¶
Package config contains the HCL config structs
Index ¶
- Constants
- Variables
- type Agent
- type CronScheduleOptions
- type DatetimeScheduleOptions
- type Deployment
- type HCLConfig
- type JWT
- type LifecycleStage
- type LifecycleTemplate
- func (t *LifecycleTemplate) BuildStateMachine() (*statemachine.StateMachine, error)
- func (t *LifecycleTemplate) GetAction(path string) (*PipelineAction, bool)
- func (t *LifecycleTemplate) GetEnvironmentNames() []string
- func (t *LifecycleTemplate) GetJSONWebTokens() []*JWT
- func (t *LifecycleTemplate) GetLifecycleNode(path string) (interface{}, bool)
- func (t *LifecycleTemplate) GetNestedPipeline(path string) (*NestedPipeline, bool)
- func (t *LifecycleTemplate) GetPlugins() []*Plugin
- func (t *LifecycleTemplate) GetStageOrder() []string
- func (t *LifecycleTemplate) GetTask(path string) (*PipelineTask, bool)
- func (t *LifecycleTemplate) GetVCSTokens() []*VCSToken
- func (t *LifecycleTemplate) GetVariableBodies() map[string]hcl.Body
- func (t *LifecycleTemplate) Validate() error
- type MountPoint
- type NestedPipeline
- type Option
- type PipelineAction
- type PipelineCondition
- type PipelineNodeSchedule
- type PipelineNodeScheduleType
- type PipelineStage
- type PipelineTask
- type PipelineTemplate
- func (pc *PipelineTemplate) BuildStateMachine() (*statemachine.StateMachine, error)
- func (pc *PipelineTemplate) GetAction(path string) (*PipelineAction, bool)
- func (pc *PipelineTemplate) GetJSONWebTokens() []*JWT
- func (pc *PipelineTemplate) GetNestedPipeline(path string) (*NestedPipeline, bool)
- func (pc *PipelineTemplate) GetPipelineNode(path string) (interface{}, bool)
- func (pc *PipelineTemplate) GetPlugins() []*Plugin
- func (pc *PipelineTemplate) GetStageOrder() []string
- func (pc *PipelineTemplate) GetTask(path string) (*PipelineTask, bool)
- func (pc *PipelineTemplate) GetVCSTokens() []*VCSToken
- func (pc *PipelineTemplate) GetVariableBodies() map[string]hcl.Body
- func (pc *PipelineTemplate) GetVolume(name string) (*Volume, bool)
- func (pc *PipelineTemplate) Validate() error
- type Plugin
- type PluginRequirement
- type PluginRequirements
- type VCSOptions
- type VCSToken
- type Variable
- type Volume
Constants ¶
const (
// MaximumAllowedNodes is the maximum number of nodes allowed in an HCL config
MaximumAllowedNodes = 10
)
Variables ¶
var NameRegex = regexp.MustCompile("^[0-9a-z](?:[0-9a-z-_]{0,62}[0-9a-z])?$")
NameRegex allows letters, numbers with - and _ allowed in non leading or trailing positions, max length is 64
Functions ¶
This section is empty.
Types ¶
type Agent ¶
type Agent struct {
Tags []string `hcl:"tags,optional"`
}
Agent represents configuration related to an agent
type CronScheduleOptions ¶ added in v0.9.0
CronScheduleOptions represents the options for a cron schedule
func (*CronScheduleOptions) Validate ¶ added in v0.9.0
func (c *CronScheduleOptions) Validate() error
Validate validates the cron schedule options
type DatetimeScheduleOptions ¶ added in v0.9.0
DatetimeScheduleOptions represents the options for a datetime schedule
type Deployment ¶
type Deployment struct { ApprovalRules hcl.Expression `hcl:"approval_rules,optional"` When *string `hcl:"when,optional"` OnError *string `hcl:"on_error,optional"` EnvironmentName string `hcl:"environment"` Dependencies []string `hcl:"dependencies,optional"` Schedule *PipelineNodeSchedule `hcl:"schedule,block"` }
Deployment represents a deployment of a release (a pipeline)
func (*Deployment) Validate ¶
func (d *Deployment) Validate() error
Validate validates the deployment
type HCLConfig ¶
type HCLConfig interface { Validate() error BuildStateMachine() (*statemachine.StateMachine, error) GetPlugins() []*Plugin GetVariableBodies() map[string]hcl.Body GetAction(path string) (*PipelineAction, bool) GetTask(path string) (*PipelineTask, bool) GetNestedPipeline(path string) (*NestedPipeline, bool) GetJSONWebTokens() []*JWT GetVCSTokens() []*VCSToken }
HCLConfig is an interface that represents a HCL config
type LifecycleStage ¶
type LifecycleStage struct { PreTasks *PipelineCondition `hcl:"pre,block"` PostTasks *PipelineCondition `hcl:"post,block"` Name string `hcl:",label"` Deployments []*Deployment `hcl:"deployment,block"` }
LifecycleStage is a stage in a lifecycle
func (*LifecycleStage) Validate ¶
func (s *LifecycleStage) Validate() error
Validate validates the lifecycle stage
type LifecycleTemplate ¶
type LifecycleTemplate struct { Body hcl.Body `hcl:",body"` Stages []*LifecycleStage `hcl:"stage,block"` StageOrder []string `hcl:"stage_order,optional"` Variables []*Variable `hcl:"variable,block"` Plugins []*Plugin `hcl:"plugin,block"` PluginRequirements *PluginRequirements `hcl:"plugin_requirements,block"` JSONWebTokens []*JWT `hcl:"jwt,block"` Volumes []*Volume `hcl:"volume,block"` VCSTokens []*VCSToken `hcl:"vcs_token,block"` }
LifecycleTemplate is an HCL definition of a lifecycle
func NewLifecycleTemplate ¶
func NewLifecycleTemplate(reader io.Reader) (*LifecycleTemplate, []byte, error)
NewLifecycleTemplate creates a new lifecycle template
func (*LifecycleTemplate) BuildStateMachine ¶
func (t *LifecycleTemplate) BuildStateMachine() (*statemachine.StateMachine, error)
BuildStateMachine builds the lifecycle state machine.
func (*LifecycleTemplate) GetAction ¶
func (t *LifecycleTemplate) GetAction(path string) (*PipelineAction, bool)
GetAction returns a lifecycle action based on the provided path.
func (*LifecycleTemplate) GetEnvironmentNames ¶
func (t *LifecycleTemplate) GetEnvironmentNames() []string
GetEnvironmentNames returns the environment names defined in the lifecycle template
func (*LifecycleTemplate) GetJSONWebTokens ¶
func (t *LifecycleTemplate) GetJSONWebTokens() []*JWT
GetJSONWebTokens returns the JWTs defined in the lifecycle template
func (*LifecycleTemplate) GetLifecycleNode ¶
func (t *LifecycleTemplate) GetLifecycleNode(path string) (interface{}, bool)
GetLifecycleNode returns a lifecycle node based on the path.
func (*LifecycleTemplate) GetNestedPipeline ¶ added in v0.3.0
func (t *LifecycleTemplate) GetNestedPipeline(path string) (*NestedPipeline, bool)
GetNestedPipeline returns a lifecycle pipeline (deployment) based on the provided path.
func (*LifecycleTemplate) GetPlugins ¶
func (t *LifecycleTemplate) GetPlugins() []*Plugin
GetPlugins returns the plugins defined in the lifecycle template
func (*LifecycleTemplate) GetStageOrder ¶
func (t *LifecycleTemplate) GetStageOrder() []string
GetStageOrder returns the specified stage order or the default ordering of the stages.
func (*LifecycleTemplate) GetTask ¶
func (t *LifecycleTemplate) GetTask(path string) (*PipelineTask, bool)
GetTask returns a lifecycle task based on the provided path
func (*LifecycleTemplate) GetVCSTokens ¶ added in v0.8.0
func (t *LifecycleTemplate) GetVCSTokens() []*VCSToken
GetVCSTokens returns the VCS tokens defined in the lifecycle template
func (*LifecycleTemplate) GetVariableBodies ¶
func (t *LifecycleTemplate) GetVariableBodies() map[string]hcl.Body
GetVariableBodies returns the HCL body for each variable definition
func (*LifecycleTemplate) Validate ¶
func (t *LifecycleTemplate) Validate() error
Validate validates the lifecycle template
type MountPoint ¶
MountPoint defines the location where a Volume will be mounted within a pipeline construct.
type NestedPipeline ¶
type NestedPipeline struct { Variables hcl.Expression `hcl:"variables,optional"` TemplateID hcl.Expression `hcl:"template_id"` ApprovalRules hcl.Expression `hcl:"approval_rules,optional"` EnvironmentName *string `hcl:"environment,optional"` When *string `hcl:"when,optional"` PipelineType *string `hcl:"pipeline_type,optional"` OnError *string `hcl:"on_error,optional"` Schedule *PipelineNodeSchedule `hcl:"schedule,block"` Name string `hcl:",label"` Dependencies []string `hcl:"dependencies,optional"` }
NestedPipeline represents a nested pipeline
func (*NestedPipeline) Validate ¶
func (p *NestedPipeline) Validate() error
Validate validates the nested pipeline
type Option ¶
type Option func(*options)
Option for creating a template
func WithUnknownVars ¶
func WithUnknownVars() Option
WithUnknownVars will use a cty unknown type for any variables that are not defined
type PipelineAction ¶
type PipelineAction struct { Alias *string `hcl:"alias,optional"` Body hcl.Body `hcl:",body"` Remain hcl.Body `hcl:",remain"` Label string `hcl:",label"` }
PipelineAction represents an action that will be executed using a plugin
func (*PipelineAction) PluginActionName ¶
func (p *PipelineAction) PluginActionName() string
PluginActionName returns the action name within the plugin
func (*PipelineAction) PluginName ¶
func (p *PipelineAction) PluginName() string
PluginName returns the plugin name for this action
func (*PipelineAction) Validate ¶
func (p *PipelineAction) Validate() error
Validate validates the pipeline action
type PipelineCondition ¶
type PipelineCondition struct {
Tasks []*PipelineTask `hcl:"task,block"`
}
PipelineCondition represents a condition that must be met for a pipeline task to be executed (pre/post)
func (*PipelineCondition) Validate ¶
func (p *PipelineCondition) Validate() error
Validate validates the pipeline condition
type PipelineNodeSchedule ¶ added in v0.9.0
type PipelineNodeSchedule struct { Options map[string]string `hcl:"options,attr"` Type PipelineNodeScheduleType `hcl:"type,attr"` }
PipelineNodeSchedule represents the schedule for a pipeline node
func (*PipelineNodeSchedule) GetCronOptions ¶ added in v0.9.0
func (s *PipelineNodeSchedule) GetCronOptions() (*CronScheduleOptions, error)
GetCronOptions returns the cron options for the schedule
func (*PipelineNodeSchedule) GetDatetimeOptions ¶ added in v0.9.0
func (s *PipelineNodeSchedule) GetDatetimeOptions() (*DatetimeScheduleOptions, error)
GetDatetimeOptions returns the datetime options for the schedule
func (*PipelineNodeSchedule) Validate ¶ added in v0.9.0
func (s *PipelineNodeSchedule) Validate() error
Validate validates the schedule
type PipelineNodeScheduleType ¶ added in v0.9.0
type PipelineNodeScheduleType string
PipelineNodeScheduleType is the type of schedule for a pipeline node
const ( CronScheduleType PipelineNodeScheduleType = "cron" DatetimeScheduleType PipelineNodeScheduleType = "datetime" )
PipelineNodeScheduleType constants
type PipelineStage ¶
type PipelineStage struct { NestedPipelines []*NestedPipeline `hcl:"pipeline,block"` PreTasks *PipelineCondition `hcl:"pre,block"` PostTasks *PipelineCondition `hcl:"post,block"` Name string `hcl:",label"` Tasks []*PipelineTask `hcl:"task,block"` }
PipelineStage is a stage in a pipeline
func (*PipelineStage) Validate ¶
func (p *PipelineStage) Validate() error
Validate validates the pipeline stage
type PipelineTask ¶
type PipelineTask struct { SuccessCondition hcl.Expression `hcl:"success_condition,optional"` ApprovalRules hcl.Expression `hcl:"approval_rules,optional"` When *string `hcl:"when,optional"` Interval *string `hcl:"interval,optional"` Attempts *int `hcl:"attempts,optional"` Image *string `hcl:"image,optional"` Agent *Agent `hcl:"agent,block"` OnError *string `hcl:"on_error,optional"` Name string `hcl:",label"` Dependencies []string `hcl:"dependencies,optional"` MountPoints []*MountPoint `hcl:"mount_point,block"` Actions []*PipelineAction `hcl:"action,block"` Schedule *PipelineNodeSchedule `hcl:"schedule,block"` }
PipelineTask defines a unit of work to be performed within a pipeline
func (*PipelineTask) Validate ¶
func (p *PipelineTask) Validate() error
Validate validates the pipeline task
type PipelineTemplate ¶
type PipelineTemplate struct { Body hcl.Body `hcl:",body"` Stages []*PipelineStage `hcl:"stage,block"` StageOrder []string `hcl:"stage_order,optional"` Agent *Agent `hcl:"agent,block"` Variables []*Variable `hcl:"variable,block"` Plugins []*Plugin `hcl:"plugin,block"` PluginRequirements *PluginRequirements `hcl:"plugin_requirements,block"` JSONWebTokens []*JWT `hcl:"jwt,block"` Volumes []*Volume `hcl:"volume,block"` VCSTokens []*VCSToken `hcl:"vcs_token,block"` }
PipelineTemplate is an HCL definition of a pipeline
func NewPipelineTemplate ¶
func NewPipelineTemplate(reader io.Reader, variables map[string]string, opts ...Option) (*PipelineTemplate, []byte, error)
NewPipelineTemplate creates a new pipeline template
func (*PipelineTemplate) BuildStateMachine ¶
func (pc *PipelineTemplate) BuildStateMachine() (*statemachine.StateMachine, error)
BuildStateMachine builds a state machine based on the pipeline template
func (*PipelineTemplate) GetAction ¶
func (pc *PipelineTemplate) GetAction(path string) (*PipelineAction, bool)
GetAction returns a pipeline action based on the provided path
func (*PipelineTemplate) GetJSONWebTokens ¶
func (pc *PipelineTemplate) GetJSONWebTokens() []*JWT
GetJSONWebTokens returns the JWTs defined in the pipeline template
func (*PipelineTemplate) GetNestedPipeline ¶ added in v0.3.0
func (pc *PipelineTemplate) GetNestedPipeline(path string) (*NestedPipeline, bool)
GetNestedPipeline returns a nested pipeline based on the provided path
func (*PipelineTemplate) GetPipelineNode ¶
func (pc *PipelineTemplate) GetPipelineNode(path string) (interface{}, bool)
GetPipelineNode returns a pipeline node based on the provided path
func (*PipelineTemplate) GetPlugins ¶
func (pc *PipelineTemplate) GetPlugins() []*Plugin
GetPlugins returns the plugins defined in the pipeline template
func (*PipelineTemplate) GetStageOrder ¶
func (pc *PipelineTemplate) GetStageOrder() []string
GetStageOrder returns the specified stage order or the default ordering of the stages.
func (*PipelineTemplate) GetTask ¶
func (pc *PipelineTemplate) GetTask(path string) (*PipelineTask, bool)
GetTask returns a pipeline task based on the provided path
func (*PipelineTemplate) GetVCSTokens ¶ added in v0.8.0
func (pc *PipelineTemplate) GetVCSTokens() []*VCSToken
GetVCSTokens returns the VCS tokens defined in the pipeline template
func (*PipelineTemplate) GetVariableBodies ¶
func (pc *PipelineTemplate) GetVariableBodies() map[string]hcl.Body
GetVariableBodies returns the HCL body for each variable definition
func (*PipelineTemplate) GetVolume ¶
func (pc *PipelineTemplate) GetVolume(name string) (*Volume, bool)
GetVolume returns the specified volume by name.
func (*PipelineTemplate) Validate ¶
func (pc *PipelineTemplate) Validate() error
Validate validates the pipeline template
type Plugin ¶
type Plugin struct { Body hcl.Body `hcl:",body"` Remain hcl.Body `hcl:",remain"` Name string `hcl:",label"` }
Plugin represents a plugin that is used in the pipeline
type PluginRequirement ¶
PluginRequirement represents a required plugin
func (*PluginRequirement) IsLocal ¶
func (p *PluginRequirement) IsLocal() bool
IsLocal returns true if the plugin is being used from a local source.
func (*PluginRequirement) Validate ¶
func (p *PluginRequirement) Validate() error
Validate validates a required plugin
type PluginRequirements ¶
PluginRequirements is a map of required plugins.
func (*PluginRequirements) Requirements ¶
func (p *PluginRequirements) Requirements() (map[string]PluginRequirement, error)
Requirements returns the plugins block as a map for easy access.
type VCSOptions ¶
type VCSOptions struct { Ref *string `hcl:"ref,optional"` RepositoryPath string `hcl:"repository_path,attr"` ProviderID string `hcl:"provider_id,attr"` }
VCSOptions are the configuration options for a vcs volume type.
type Variable ¶
type Variable struct { Body hcl.Body `hcl:",body"` Type hcl.Expression `hcl:"type,optional"` Default hcl.Expression `hcl:"default,optional"` Name string `hcl:",label"` }
Variable represents a pipeline variable
type Volume ¶
type Volume struct { VCSOptions *VCSOptions `hcl:"vcs_options,block"` Type string `hcl:"type,attr"` Name string `hcl:",label"` }
Volume allows mounting directories from external file systems like a VCS provider into the pipeline.