build

package
v0.0.0-...-8335c39 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2019 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StateWaiting  = "waiting"
	StateBuilding = "building"
	StateSuccess  = "succeeded"
	StateFailed   = "failed"
)

Step state constants

View Source
const (
	EventBuildStart    = "BUILD_START"
	EventTaskStart     = "TASK_START"
	EventStepStart     = "STEP_START"
	EventStepComplete  = "STEP_COMPLETE" // fires regardless of success/fail
	EventStepSuccess   = "STEP_SUCCESS"
	EventStepFail      = "STEP_FAIL"
	EventTaskComplete  = "TASK_COMPLETE" // fires regardless of success/fail
	EventTaskSuccess   = "TASK_SUCCESS"
	EventTaskFail      = "TASK_FAIL"
	EventBuildComplete = "BUILD_COMPLETE" // fires regardless of success/fail
	EventBuildSuccess  = "BUILD_SUCCESS"
	EventBuildFail     = "BUILD_FAIL"
)

Event constants for Task_* we can add a modifier to specify *which* task e.g. TASK_COMPLETE-<task_name> for Step_* we can add a modifier to specify *which* step (in the currently building task) e.g. STEP_COMPLETE-<step_name>

Variables

This section is empty.

Functions

func GetAddressAuthTokensMap

func GetAddressAuthTokensMap(dockerRegistries []DockerRegistry) (r map[string]string)

func GetAuthConfigsMap

func GetAuthConfigsMap(dockerRegistries []DockerRegistry) map[string]types.AuthConfig

func GetGlobalParams

func GetGlobalParams(writer io.Writer, projectRoot, branch string) (map[string]Parameter, error)

Types

type BackupResolver

type BackupResolver interface {
	Resolve(paramName string) (string, error)
}

type BaseStep

type BaseStep struct {
	ID          string `json:"id"`
	Type        string `json:"type" yaml:"type"`
	Description string `json:"description" yaml:"description"`

	OutputStreams []*Stream  `json:"outputStreams" yaml:"-"`
	Status        string     `json:"status"`
	StartedAt     *time.Time `json:"startedAt"`
	UpdatedAt     *time.Time `json:"updatedAt"`
	CompletedAt   *time.Time `json:"completedAt"`
}

func (*BaseStep) GetDescription

func (bS *BaseStep) GetDescription() string

func (*BaseStep) GetID

func (bS *BaseStep) GetID() string

func (*BaseStep) GetOutputStreams

func (bS *BaseStep) GetOutputStreams() []*Stream

func (*BaseStep) GetStreamID

func (bS *BaseStep) GetStreamID(streamName string) (string, error)

func (*BaseStep) GetStreamWriter

func (bS *BaseStep) GetStreamWriter(emitter Emitter, streamName string) (StreamWriter, error)

func (*BaseStep) GetType

func (bS *BaseStep) GetType() string

type BlankEmitter

type BlankEmitter struct {
}

func NewBlankEmitter

func NewBlankEmitter() *BlankEmitter

func (*BlankEmitter) GetStepWriter

func (w *BlankEmitter) GetStepWriter(Step) StepWriter

func (*BlankEmitter) GetStreamWriter

func (w *BlankEmitter) GetStreamWriter(*Stream) StreamWriter

func (*BlankEmitter) GetTaskWriter

func (w *BlankEmitter) GetTaskWriter(*Task) TaskWriter

type BlankWriter

type BlankWriter struct {
}

func (BlankWriter) Close

func (w BlankWriter) Close()

func (BlankWriter) SetStatus

func (w BlankWriter) SetStatus(s string)

func (BlankWriter) Write

func (w BlankWriter) Write(p []byte) (n int, err error)

type ConstructionPlan

type ConstructionPlan struct {
	ID     string   `json:"id"`
	Name   string   `json:"name"`
	Stages []*Stage `json:"stages"`
}

ConstructionPlan represents a collection of Stages to be executed in order.

func NewConstructionPlanFromBlueprint

func NewConstructionPlanFromBlueprint(
	targetBlueprintName string,
	blueprints []*config.Blueprint,
	paramResolver BackupResolver,
	repository *git.Repository,
	branch string,
	commitSha string,
	projectRoot string,
) (*ConstructionPlan, error)

func NewConstructionPlanFromPipeline

func NewConstructionPlanFromPipeline(
	targetPipelineName string,
	pipelines []*config.Pipeline,
	blueprints []*config.Blueprint,
	paramResolver BackupResolver,
	repository *git.Repository,
	branch string,
	commitSha string,
	projectRoot string,
) (*ConstructionPlan, error)

func (*ConstructionPlan) Execute

func (p *ConstructionPlan) Execute(emitter Emitter) error

func (*ConstructionPlan) Stop

func (p *ConstructionPlan) Stop() error

type DockerRegistry

type DockerRegistry struct {
	Address            string            `json:"address"`
	Use                string            `json:"use"`
	Arguments          map[string]string `json:"arguments"`
	AuthorizationToken string            `json:"authToken"`
}

type Emitter

type Emitter interface {
	GetStreamWriter(*Stream) StreamWriter
	GetStepWriter(Step) StepWriter
	GetTaskWriter(*Task) TaskWriter
}

Emitter for forwarding bytes of output onwards

type Parameter

type Parameter struct {
	Name     string `json:"name"`
	Value    string `json:"value"`
	IsSecret bool   `json:"isSecret"`
}

type Setup

type Setup struct {
	BaseStep
	// contains filtered or unexported fields
}

func NewStepSetup

func NewStepSetup(
	resolver BackupResolver,
	repository *git.Repository,
	branch,
	commitSha string,
) *Setup

func (*Setup) Execute

func (s *Setup) Execute(emitter Emitter, t *Task) error

func (Setup) GetDetails

func (s Setup) GetDetails() string

func (*Setup) SetParams

func (s *Setup) SetParams(params map[string]*Parameter) error

func (*Setup) Stop

func (s *Setup) Stop() error

func (Setup) Validate

func (s Setup) Validate(params map[string]Parameter) error

type Stage

type Stage struct {
	ID     string `json:"id"`
	Index  uint16 `json:"index"`
	Status string `json:"status"`
	// k: Task.ID
	Tasks map[string]*Task `json:"tasks"`
}

Stage represents a set of Tasks that can run in parallel, therefore Tasks is a map[TaskID]Task.

type Step

type Step interface {
	GetID() string
	Execute(emitter Emitter, t *Task) error
	Stop() error
	GetType() string
	GetDescription() string
	GetDetails() string
	SetParams(map[string]*Parameter) error
	GetOutputStreams() []*Stream

	Validate(map[string]Parameter) error
}

type StepDockerBuild

type StepDockerBuild struct {
	BaseStep
	Dockerfile string   `json:"dockerfile"`
	Context    string   `json:"context"`
	Tags       []string `json:"tags"`
	// contains filtered or unexported fields
}

func NewStepDockerBuild

func NewStepDockerBuild(c *config.StepDockerBuild) *StepDockerBuild

func (*StepDockerBuild) Execute

func (dB *StepDockerBuild) Execute(emitter Emitter, t *Task) error

func (StepDockerBuild) GetDetails

func (dB StepDockerBuild) GetDetails() string

func (*StepDockerBuild) SetParams

func (dB *StepDockerBuild) SetParams(params map[string]*Parameter) error

func (*StepDockerBuild) Stop

func (dB *StepDockerBuild) Stop() error

func (*StepDockerBuild) Validate

func (dB *StepDockerBuild) Validate(params map[string]Parameter) error

type StepDockerCompose

type StepDockerCompose struct {
	BaseStep
	ComposeFilePath string `json:"composeFile"`
	// contains filtered or unexported fields
}

func NewStepDockerCompose

func NewStepDockerCompose(c *config.StepDockerCompose, projectRoot string) *StepDockerCompose

func (*StepDockerCompose) Execute

func (dC *StepDockerCompose) Execute(emitter Emitter, t *Task) error

func (StepDockerCompose) GetDetails

func (dC StepDockerCompose) GetDetails() string

func (*StepDockerCompose) SetParams

func (dC *StepDockerCompose) SetParams(params map[string]*Parameter) error

func (*StepDockerCompose) Stop

func (dC *StepDockerCompose) Stop() error

func (*StepDockerCompose) Validate

func (dC *StepDockerCompose) Validate(params map[string]Parameter) error

type StepDockerPush

type StepDockerPush struct {
	BaseStep
	Tags []string `json:"tags"`
	// contains filtered or unexported fields
}

func NewStepDockerPush

func NewStepDockerPush(c *config.StepDockerPush) *StepDockerPush

func (*StepDockerPush) Execute

func (dP *StepDockerPush) Execute(emitter Emitter, tsk *Task) error

func (StepDockerPush) GetDetails

func (dP StepDockerPush) GetDetails() string

func (*StepDockerPush) SetParams

func (dP *StepDockerPush) SetParams(params map[string]*Parameter) error

func (*StepDockerPush) Stop

func (dP *StepDockerPush) Stop() error

func (StepDockerPush) Validate

func (dP StepDockerPush) Validate(params map[string]Parameter) error

type StepDockerRun

type StepDockerRun struct {
	BaseStep
	Image          string            `json:"image"`
	Command        []string          `json:"command"`
	Environment    map[string]string `json:"environment"`
	WorkingDir     string            `json:"workingDir"`
	MountPoint     string            `json:"mountPoint"`
	IgnoreExitCode bool              `json:"ignoreExitCode"`
	// contains filtered or unexported fields
}

func NewStepDockerRun

func NewStepDockerRun(c *config.StepDockerRun) *StepDockerRun

func (*StepDockerRun) Execute

func (dR *StepDockerRun) Execute(emitter Emitter, t *Task) error

func (StepDockerRun) GetDetails

func (dR StepDockerRun) GetDetails() string

func (*StepDockerRun) SetParams

func (dR *StepDockerRun) SetParams(params map[string]*Parameter) error

func (*StepDockerRun) Stop

func (dR *StepDockerRun) Stop() error

func (StepDockerRun) Validate

func (dR StepDockerRun) Validate(params map[string]Parameter) error

type StepWriter

type StepWriter interface {
	Write(p []byte) (n int, err error)
	SetStatus(s string)
	Close()
}

type Stoppable

type Stoppable interface {
	Stop() error
}

type Stream

type Stream struct {
	ID     string  `json:"id"`
	Name   string  `json:"name"`
	Status string  `json:"status"`
	Source *string `json:"source"`
}

type StreamLine

type StreamLine struct {
	LineNumber uint64    `json:"lineNumber"`
	Timestamp  time.Time `json:"timestamp"`
	Output     string    `json:"output"`
}

type StreamWriter

type StreamWriter interface {
	Write(p []byte) (n int, err error)
	SetStatus(s string)
	Close()
}

type Task

type Task struct {
	ID string `json:"id"`

	Blueprint    config.Blueprint `json:"blueprint"`
	IgnoreErrors bool             `json:"ignoreErrors"`
	Docker       TaskDocker       `json:"docker"`
	Steps        []Step           `json:"steps"`

	Status      string     `json:"status"`
	StartedAt   *time.Time `json:"startedAt"`
	UpdatedAt   *time.Time `json:"updatedAt"`
	CompletedAt *time.Time `json:"completedAt"`

	ProjectRoot string `json:"-"`
	// contains filtered or unexported fields
}

func NewTask

func NewTask(
	c *config.Blueprint,
	paramResolver BackupResolver,
	repository *git.Repository,
	branch string,
	commitSha string,
	projectRoot string,
) *Task

func (*Task) Execute

func (t *Task) Execute(emitter Emitter) error

func (*Task) Stop

func (t *Task) Stop() error

func (*Task) UnmarshalJSON

func (t *Task) UnmarshalJSON(b []byte) error

func (*Task) UpdateSetup

func (t *Task) UpdateSetup(
	backupResolver BackupResolver,
	repository *git.Repository,
	branch string,
	commitSha string,
)

type TaskDocker

type TaskDocker struct {
	Registries []DockerRegistry `json:"registries"`
}

type TaskWriter

type TaskWriter interface {
	Write(p []byte) (n int, err error)
	SetStatus(s string)
	Close()
}

Jump to

Keyboard shortcuts

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