codebuild

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: May 24, 2019 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildCommand added in v0.4.0

func BuildCommand() cli.Command

BuildCommand registers a cli.Command

func RunCommand

func RunCommand() cli.Command

RunCommand registers a cli.Command

Types

type Artifacts

type Artifacts struct {
	Files         interface{} `json:"files"`
	DiscardPaths  string      `json:"discard-paths"` // default=yes
	BaseDirectory string      `json:"base-directory"`
}

Artifacts describes contents specified in top-root `artifacts` key of the `buildspec.yml` file.

func (Artifacts) List

func (a Artifacts) List() ([]string, error)

List returns list of files defined in the OutputArtifact

type BuildSpec

type BuildSpec struct {
	Version   string    `json:"version"`
	Env       Env       `json:"env"`
	Phases    Phases    `json:"phases"`
	Artifacts Artifacts `json:"artifacts"`
}

BuildSpec defines top-root contents of `buildspec.yml` file.

See: - https://docs.aws.amazon.com/codebuild/latest/userguide/build-spec-ref.html

func ParseBuildSpec

func ParseBuildSpec(filePath string) (bs BuildSpec, err error)

ParseBuildSpec unmarshals contents of the `buildspec.yml` file to the newly- created BuildSpec struct.

type CodeBuild

type CodeBuild struct {
	Definition BuildSpec
	Project    cloudformation.AWSCodeBuildProject
	Pipeline   *ci.Pipeline
	Script     *ShellScript
}

CodeBuild mimics AWS CodeBuild runtime for the localcb

func NewCodeBuild

func NewCodeBuild(project cloudformation.AWSCodeBuildProject) (*CodeBuild, error)

NewCodeBuild creates new CodeBuild pipeline runtime

func (*CodeBuild) CreateContainer

CreateContainer creates a Docker container with given configuration

func (*CodeBuild) DryRun added in v0.5.0

func (cb *CodeBuild) DryRun(cfg RunConfiguration)

func (*CodeBuild) EnvVariables

func (cb *CodeBuild) EnvVariables(customVariables []string) []string

EnvVariables binds all variables to one common []string slice which can be further passed to the Docker client.

func (*CodeBuild) NewDefaultVariables

func (cb *CodeBuild) NewDefaultVariables() DefaultVariables

NewDefaultVariables parses all variables provided by default by the CodeBuild and returns them formatted for the Docker client. See: https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-env-vars.html

func (*CodeBuild) PhaseToStage

func (cb *CodeBuild) PhaseToStage(p Phase, name string)

PhaseToStage parses codebuild.Phase as a ci.Stage

func (*CodeBuild) PhasesAsStages

func (cb *CodeBuild) PhasesAsStages()

PhasesAsStages converts all codebuild.Phases to ci.Stages

func (*CodeBuild) RunInContainer

func (cb *CodeBuild) RunInContainer(cfg RunConfiguration) error

RunInContainer starts Docker container and executes localcb.sh shell script

func (*CodeBuild) SaveScript

func (cb *CodeBuild) SaveScript(location string) error

SaveScript creates script (i.e. shell) file on host, which can be futher used by the localcb during the runtime.

func (*CodeBuild) StagesAsScript

func (cb *CodeBuild) StagesAsScript(baseDir, scriptFile string) error

StagesAsScript saves a localcb.sh shell script into given basedir

func (*CodeBuild) Validate

func (cb *CodeBuild) Validate(cfg RunConfiguration) error

func (*CodeBuild) Volumes

func (cb *CodeBuild) Volumes(customVolumes []string) ([]string, error)

Volumes returns volumes for the Docker client

func (*CodeBuild) WorkingDirectory

func (cb *CodeBuild) WorkingDirectory(customWorkDir string) string

WorkingDirectory returns working directory for the Docker client

type DefaultVariables

type DefaultVariables struct {
	AwsDefaultRegion               string `env:"AWS_DEFAULT_REGION"`
	AwsRegion                      string `env:"AWS_REGION"`
	CodeBuildBuildArn              string `env:"CODEBUILD_BUILD_ARN"`
	CodeBuildBuildID               string `env:"CODEBUILD_BUILD_ID"`
	CodeBuildBuildImage            string `env:"CODEBUILD_BUILD_IMAGE"`
	CodeBuildBuildSucceeding       string `env:"CODEBUILD_BUILD_SUCCEEDING"`
	CodeBuildInitiator             string `env:"CODEBUILD_INITIATOR"`
	CodeBuildKMSKeyID              string `env:"CODEBUILD_KMS_KEY_ID"`
	CodeBuildResolvedSourceVersion string `env:"CODEBUILD_RESOLVED_SOURCE_VERSION"`
	CodeBuildSourceRepoURL         string `env:"CODEBUILD_SOURCE_REPO_URL"`
	CodeBuildSourceVersion         string `env:"CODEBUILD_SOURCE_VERSION"`
	CodeBuildSrcDir                string `env:"CODEBUILD_SRC_DIR"`
	Home                           string `env:"HOME"`
}

DefaultVariables contains default variables provided by the CodeBuild See: https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-env-vars.html

func (DefaultVariables) KeyValues

func (dv DefaultVariables) KeyValues() []string

KeyValues returns a list of environment variables for the Docker client in key=value format.

type Env

type Env struct {
	Variables map[string]string `json:"variables"`
}

Env describes contents specified in top-root `env` key of the `builspec.yml` file.

type Phase

type Phase struct {
	Commands []string `json:"commands"`
}

Phase provides command list which will be run during the build.

type Phases

type Phases struct {
	Install   Phase `json:"install"`
	PreBuild  Phase `json:"pre_build"`
	Build     Phase `json:"build"`
	PostBuild Phase `json:"post_build"`
}

Phases describes contents specified in top-root `phases` key of the `buildspec.yml` file.

type RunConfiguration

type RunConfiguration struct {
	LogFile          string
	EnvVariables     []string
	WorkingDirectory string
	Volume           []string
	ForcePullImage   bool
	NetworkName      string

	ContainerName string
}

type ShellScript

type ShellScript struct {
	Buffer *bytes.Buffer
}

ShellScript transforms CodeBuild definition file to localcb.sh shell script

func NewShellScript

func NewShellScript() *ShellScript

NewShellScript creates new ShellScript with a brand new buffer

func (*ShellScript) ExtractStage

func (sr *ShellScript) ExtractStage(stage *ci.Stage) error

Jump to

Keyboard shortcuts

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