config

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2024 License: MPL-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package config contains the HCL config structs

Index

Constants

This section is empty.

Variables

View Source
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

func (*Agent) Validate

func (p *Agent) Validate() error

Validate validates the agent

type Deployment

type Deployment struct {
	ApprovalRules   []string `hcl:"approval_rules,optional"`
	When            *string  `hcl:"when,optional"`
	EnvironmentName string   `hcl:"environment"`
	Dependencies    []string `hcl:"dependencies,optional"`
}

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)
	GetJSONWebTokens() []*JWT
}

HCLConfig is an interface that represents a HCL config

type JWT

type JWT struct {
	Name     string `hcl:",label"`
	Audience string `hcl:"audience,attr"`
}

JWT represents a pipeline JSON Web Token

func (*JWT) Validate

func (j *JWT) Validate() error

Validate validates a JWT

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"`
}

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

type MountPoint struct {
	Path   *string `hcl:"path,optional"`
	Volume string  `hcl:"volume,attr"`
}

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"`
	EnvironmentName *string        `hcl:"environment,optional"`
	When            *string        `hcl:"when,optional"`
	PipelineType    *string        `hcl:"pipeline_type,optional"`
	Name            string         `hcl:",label"`
	Dependencies    []string       `hcl:"dependencies,optional"`
	ApprovalRules   []string       `hcl:"approval_rules,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 new pipeline 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) Name

func (p *PipelineAction) Name() string

Name returns the action name

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 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 {
	Dependencies     []string          `hcl:"dependencies,optional"`
	SuccessCondition hcl.Expression    `hcl:"success_condition,optional"`
	ApprovalRules    []string          `hcl:"approval_rules,optional"`
	When             *string           `hcl:"when,optional"`
	Interval         *string           `hcl:"interval,optional"`
	Attempts         *int              `hcl:"attempts,optional"`
	Agent            *Agent            `hcl:"agent,block"`
	MountPoints      []*MountPoint     `hcl:"mount_point,block"`
	Name             string            `hcl:",label"`
	Actions          []*PipelineAction `hcl:"action,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"`
}

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

type PluginRequirement struct {
	Replace *string
	Version *string
	Source  string
}

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

type PluginRequirements struct {
	Attributes map[string]cty.Value `hcl:",remain"`
}

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

func (*Variable) Validate

func (v *Variable) Validate() error

Validate validates a 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.

func (*Volume) Validate

func (v *Volume) Validate() error

Validate validates the volume.

Jump to

Keyboard shortcuts

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