core

package
v0.0.0-...-6e3d6eb Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2017 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Logs is the event when wercker generate logs
	Logs = "Logs"

	// BuildStarted is the event when wercker has started a build.
	BuildStarted = "BuildStarted"

	// BuildFinished occures when a pipeline finishes the main phase. It is
	// possible that after-steps are run after this event.
	BuildFinished = "BuildFinished"

	// BuildStepsAdded is the event when wercker has parsed the wercker.yml and
	// has valdiated that the steps exist.
	BuildStepsAdded = "BuildStepsAdded"

	// BuildStepStarted is the event when wercker has started a new buildstep.
	BuildStepStarted = "BuildStepStarted"

	// BuildStepFinished is the event when wercker has finished a buildstep.
	BuildStepFinished = "BuildStepFinished"

	// FullPipelineFinished occurs when a pipeline finishes all it's steps,
	// included after-steps.
	FullPipelineFinished = "FullPipelineFinished"
)

Variables

View Source
var (
	DEFAULT_BASE_URL = "https://app.wercker.com"
)

Functions

func EmptyEnv

func EmptyEnv() *util.Environment

func GenerateBaseKey

func GenerateBaseKey(options *PipelineOptions) string

GenerateBaseKey generates the base key based on ApplicationID and either DeployID or BuilID

func IsBuildID

func IsBuildID(input string) bool

IsBuildID checks if input is a BuildID. BuildID is defined as a 24 character hex string.

func NewEmitterContext

func NewEmitterContext(ctx context.Context) context.Context

NewEmitterContext gives us a new context with an emitter

func ParseApplicationID

func ParseApplicationID(input string) (username, name string, err error)

ParseApplicationID parses input and returns the username and application name. A valid application ID is two strings separated by a /.

func ReadWerckerYaml

func ReadWerckerYaml(searchDirs []string, allowDefault bool) ([]byte, error)

ReadWerckerYaml will try to find a wercker.yml file and return its bytes. TODO(termie): If allowDefault is true it will try to generate a default yaml file by inspecting the project.

Types

type AWSOptions

type AWSOptions struct {
	*GlobalOptions
	AWSAccessKeyID     string
	AWSSecretAccessKey string
	AWSRegion          string
	S3Bucket           string
	S3PartSize         int64
}

AWSOptions for our artifact storage

func NewAWSOptions

func NewAWSOptions(c util.Settings, e *util.Environment, globalOpts *GlobalOptions) (*AWSOptions, error)

NewAWSOptions constructor

type AmazonAuth

type AmazonAuth struct {
	AWSRegion     string `yaml:"aws-region"`
	AWSSecretKey  string `yaml:"aws-secret-key"`
	AWSAccessKey  string `yaml:"aws-access-key"`
	AWSRegistryID string `yaml:"aws-registry-id"`
	AWSStrictAuth bool   `yaml:"aws-strict-auth"`
}

func (AmazonAuth) ToAuthenticator

func (a AmazonAuth) ToAuthenticator(env *util.Environment) (auth.Authenticator, error)

type Artifact

type Artifact struct {
	ContainerID   string
	GuestPath     string
	HostTarPath   string
	HostPath      string
	ApplicationID string
	RunID         string
	RunStepID     string
	Bucket        string
	Key           string
	ContentType   string
	Meta          map[string]*string
}

Artifact holds the information required to extract a folder from a container and eventually upload it to S3.

func (*Artifact) Cleanup

func (art *Artifact) Cleanup() error

Cleanup removes files from the host

func (*Artifact) RemotePath

func (art *Artifact) RemotePath() string

RemotePath returns the S3 path for an artifact

func (*Artifact) URL

func (art *Artifact) URL() string

URL returns the artifact's S3 url

type Authenticatable

type Authenticatable interface {
	ToAuthenticator(*util.Environment) (auth.Authenticator, error)
}

type AzureAuth

type AzureAuth struct {
	AzureClientID          string `yaml:"azure-client-id"`
	AzureClientSecret      string `yaml:"azure-client-secret"`
	AzureSubscriptionID    string `yaml:"azure-subscription-id"`
	AzureTenantID          string `yaml:"azure-tenant-id"`
	AzureResourceGroupName string `yaml:"azure-resource-group"`
	AzureRegistryName      string `yaml:"azure-registry-name"`
	AzureLoginServer       string `yaml:"azure-login-server"`
}

func (AzureAuth) ToAuthenticator

func (a AzureAuth) ToAuthenticator(env *util.Environment) (auth.Authenticator, error)

type BasePipeline

type BasePipeline struct {
	// contains filtered or unexported fields
}

BasePipeline is the base class for Build and Deploy

func NewBasePipeline

func NewBasePipeline(args BasePipelineOptions) *BasePipeline

func (*BasePipeline) AfterSteps

func (p *BasePipeline) AfterSteps() []Step

AfterSteps is a getter for afterSteps

func (*BasePipeline) Box

func (p *BasePipeline) Box() Box

Box is a getter for the box

func (*BasePipeline) CommonEnv

func (p *BasePipeline) CommonEnv() [][]string

CommonEnv is shared by both builds and deploys

func (*BasePipeline) Env

func (p *BasePipeline) Env() *util.Environment

Env is a getter for env

func (*BasePipeline) ExportEnvironment

func (p *BasePipeline) ExportEnvironment(sessionCtx context.Context, sess *Session) error

ExportEnvironment to the session

func (*BasePipeline) LogEnvironment

func (p *BasePipeline) LogEnvironment()

LogEnvironment dumps the base environment

func (*BasePipeline) Services

func (p *BasePipeline) Services() []ServiceBox

Services is a getter for the Services

func (*BasePipeline) SetupGuest

func (p *BasePipeline) SetupGuest(sessionCtx context.Context, sess *Session) error

SetupGuest ensures that the guest is prepared to run the pipeline.

func (*BasePipeline) Steps

func (p *BasePipeline) Steps() []Step

Steps is a getter for steps

func (*BasePipeline) SyncEnvironment

func (p *BasePipeline) SyncEnvironment(sessionCtx context.Context, sess *Session) error

SyncEnvironment fetches the current environment from sess, and merges the result with p.env. This requires the `env` command to be available on the container.

type BasePipelineOptions

type BasePipelineOptions struct {
	Options    *PipelineOptions
	Config     *PipelineConfig
	Env        *util.Environment
	Box        Box
	Services   []ServiceBox
	Steps      []Step
	AfterSteps []Step
	Logger     *util.LogEntry
}

type BaseStep

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

BaseStep type for extending

func NewBaseStep

func NewBaseStep(args BaseStepOptions) *BaseStep

func (*BaseStep) Checkpoint

func (s *BaseStep) Checkpoint() string

Version getter

func (*BaseStep) Cwd

func (s *BaseStep) Cwd() string

Cwd getter

func (*BaseStep) DisplayName

func (s *BaseStep) DisplayName() string

DisplayName getter

func (*BaseStep) Env

func (s *BaseStep) Env() *util.Environment

Env getter

func (*BaseStep) ID

func (s *BaseStep) ID() string

ID getter

func (*BaseStep) Name

func (s *BaseStep) Name() string

Name getter

func (*BaseStep) Owner

func (s *BaseStep) Owner() string

Owner getter

func (*BaseStep) SafeID

func (s *BaseStep) SafeID() string

SafeID getter

func (*BaseStep) Version

func (s *BaseStep) Version() string

Version getter

type BaseStepOptions

type BaseStepOptions struct {
	DisplayName string
	Env         *util.Environment
	ID          string
	Name        string
	Owner       string
	SafeID      string
	Version     string
	Cwd         string
	Checkpoint  string
}

BaseStepOptions are exported fields so that we can make a BaseStep from other packages, see: https://gist.github.com/termie/8b66a2b4206e8e042766

type Box

type Box interface {
	GetName() string
	GetTag() string
	Repository() string
	Clean() error
	Stop()
	Commit(string, string, string, bool) (*docker.Image, error)
	Restart() (*docker.Container, error)
	AddService(ServiceBox)
	Fetch(context.Context, *util.Environment) (*docker.Image, error)
	Run(context.Context, *util.Environment) (*docker.Container, error)
	RecoverInteractive(string, Pipeline, Step) error
}

type BoxConfig

type BoxConfig struct {
	ID         string
	Name       string
	Tag        string
	Cmd        string
	Env        map[string]string
	Ports      []string
	Username   string
	Password   string
	Registry   string
	Entrypoint string
	URL        string
	Volumes    string
	Auth       Authenticatable
}

BoxConfig is the type for boxes in the config

func (*BoxConfig) IsExternal

func (c *BoxConfig) IsExternal() bool

IsExternal tells us if the box (service) is located on disk

type BoxOptions

type BoxOptions struct {
	NetworkDisabled bool
}

BoxOptions are box options, duh

type BuildFinishedArgs

type BuildFinishedArgs struct {
	Box     Box
	Options *PipelineOptions
	Result  string
}

BuildFinishedArgs contains the args associated with the "BuildFinished" event.

type BuildStartedArgs

type BuildStartedArgs struct {
	Options *PipelineOptions
}

BuildStartedArgs contains the args associated with the "BuildStarted" event.

type BuildStepFinishedArgs

type BuildStepFinishedArgs struct {
	Options     *PipelineOptions
	Box         Box
	Build       Pipeline
	Order       int
	Step        Step
	Successful  bool
	Message     string
	ArtifactURL string
	// Only applicable to the store step
	PackageURL string
	// Only applicable to the setup environment step
	WerckerYamlContents string
}

BuildStepFinishedArgs contains the args associated with the "BuildStepFinished" event.

type BuildStepStartedArgs

type BuildStepStartedArgs struct {
	Options *PipelineOptions
	Box     Box
	Build   Pipeline
	Order   int
	Step    Step
}

BuildStepStartedArgs contains the args associated with the "BuildStepStarted" event.

type BuildStepsAddedArgs

type BuildStepsAddedArgs struct {
	Build      Pipeline
	Options    *PipelineOptions
	Steps      []Step
	StoreStep  Step
	AfterSteps []Step
}

BuildStepsAddedArgs contains the args associated with the "BuildStepsAdded" event.

type CommandResult

type CommandResult struct {
	// contains filtered or unexported fields
}

CommandResult exists so that we can make a channel of them

type Config

type Config struct {
	Box               *RawBoxConfig   `yaml:"box"`
	CommandTimeout    int             `yaml:"command-timeout"`
	NoResponseTimeout int             `yaml:"no-response-timeout"`
	Services          []*RawBoxConfig `yaml:"services"`
	SourceDir         string          `yaml:"source-dir"`
	IgnoreFile        string          `yaml:"ignore-file"`
	PipelinesMap      map[string]*RawPipelineConfig
}

Config is the data type for wercker.yml

func ConfigFromYaml

func ConfigFromYaml(file []byte) (*Config, error)

ConfigFromYaml reads a []byte as yaml and turn it into a Config object

type DebugHandler

type DebugHandler struct {
	// contains filtered or unexported fields
}

DebugHandler dumps events

func NewDebugHandler

func NewDebugHandler() *DebugHandler

NewDebugHandler constructor

func (*DebugHandler) Handler

func (h *DebugHandler) Handler(name string) func(interface{})

Handler returns a per-event dumpEvent

func (*DebugHandler) ListenTo

func (h *DebugHandler) ListenTo(e *NormalizedEmitter)

ListenTo attaches to the emitter

type DetectOptions

type DetectOptions struct {
	*GlobalOptions
}

DetectOptions for detect command

func NewDetectOptions

func NewDetectOptions(c util.Settings, e *util.Environment) (*DetectOptions, error)

NewDetectOptions constructor

type DockerAuth

type DockerAuth struct {
	Username string
	Password string
	Registry string
}

func (DockerAuth) ToAuthenticator

func (d DockerAuth) ToAuthenticator(env *util.Environment) (auth.Authenticator, error)

type ExternalStep

type ExternalStep struct {
	*BaseStep
	// contains filtered or unexported fields
}

ExternalStep is the holder of the Step methods.

func NewStep

func NewStep(stepConfig *StepConfig, options *PipelineOptions) (*ExternalStep, error)

NewStep sets up the basic parts of a Step. Step names can come in a couple forms (x means currently supported):

x setup-go-environment (fetches from api)
x wercker/hipchat-notify (fetches from api)
x wercker/hipchat-notify "http://someurl/thingee.tar" (downloads tarball)
x setup-go-environment "file:///some_path" (uses local path)

func NewWerckerInitStep

func NewWerckerInitStep(options *PipelineOptions) (*ExternalStep, error)

NewWerckerInitStep returns our fake initial step

func (*ExternalStep) CachedName

func (s *ExternalStep) CachedName() string

CachedName returns a name suitable for caching

func (*ExternalStep) CollectArtifact

func (s *ExternalStep) CollectArtifact(containerID string) (*Artifact, error)

CollectArtifact noop

func (*ExternalStep) CollectFile

func (s *ExternalStep) CollectFile(containerID, path, name string, dst io.Writer) error

CollectFile noop

func (*ExternalStep) Execute

func (s *ExternalStep) Execute(sessionCtx context.Context, sess *Session) (int, error)

Execute actually sends the commands for the step.

func (*ExternalStep) Fetch

func (s *ExternalStep) Fetch() (string, error)

Fetch grabs the Step content (or calls FetchScript for script steps).

func (*ExternalStep) FetchScript

func (s *ExternalStep) FetchScript() (string, error)

FetchScript turns the raw code in a step into a shell file.

func (*ExternalStep) GuestPath

func (s *ExternalStep) GuestPath(p ...string) string

GuestPath returns a path relative to the Step on the guest.

func (*ExternalStep) HostPath

func (s *ExternalStep) HostPath(p ...string) string

HostPath returns a path relative to the Step on the host.

func (*ExternalStep) InitEnv

func (s *ExternalStep) InitEnv(env *util.Environment)

InitEnv sets up the internal environment for the Step.

func (*ExternalStep) IsScript

func (s *ExternalStep) IsScript() bool

IsScript should probably not be exported.

func (s *ExternalStep) LocalSymlink()

LocalSymlink makes sure we have an easy to use local symlink

func (*ExternalStep) MntPath

func (s *ExternalStep) MntPath(p ...string) string

MntPath returns a path relative to the read-only mount of the Step on the guest.

func (*ExternalStep) ReportPath

func (s *ExternalStep) ReportPath(p ...string) string

ReportPath returns a path to the reports for the step on the guest.

func (*ExternalStep) SetupGuest

func (s *ExternalStep) SetupGuest(sessionCtx context.Context, sess *Session) error

SetupGuest ensures that the guest is ready to run a Step.

func (*ExternalStep) ShouldSyncEnv

func (s *ExternalStep) ShouldSyncEnv() bool

ShouldSyncEnv before this step, default FALSE

type FileCollector

type FileCollector interface {
	Collect(path string) (*util.Archive, chan error)
}

FileCollector gets files out of containers

type FullPipelineFinishedArgs

type FullPipelineFinishedArgs struct {
	Options             *PipelineOptions
	MainSuccessful      bool
	RanAfterSteps       bool
	AfterStepSuccessful bool
}

FullPipelineFinishedArgs contains the args associated with the "FullPipelineFinished" event.

type GitOptions

type GitOptions struct {
	*GlobalOptions
	GitBranch     string
	GitCommit     string
	GitDomain     string
	GitOwner      string
	GitRepository string
}

GitOptions for the users, mostly

func NewGitOptions

func NewGitOptions(c util.Settings, e *util.Environment, globalOpts *GlobalOptions) (*GitOptions, error)

NewGitOptions constructor

type GlobalOptions

type GlobalOptions struct {
	BaseURL    string
	Debug      bool
	Journal    bool
	Verbose    bool
	ShowColors bool

	// Auth
	AuthToken      string
	AuthTokenStore string
}

GlobalOptions applicable to everything

func NewGlobalOptions

func NewGlobalOptions(c util.Settings, e *util.Environment) (*GlobalOptions, error)

NewGlobalOptions constructor

type InspectOptions

type InspectOptions struct {
	*PipelineOptions
}

InspectOptions for inspect command

func NewInspectOptions

func NewInspectOptions(c util.Settings, e *util.Environment) (*InspectOptions, error)

NewInspectOptions constructor

type KeenOptions

type KeenOptions struct {
	*GlobalOptions
	KeenProjectID       string
	KeenProjectWriteKey string
	ShouldKeenMetrics   bool
}

KeenOptions for our metrics

func NewKeenOptions

func NewKeenOptions(c util.Settings, e *util.Environment, globalOpts *GlobalOptions) (*KeenOptions, error)

NewKeenOptions constructor

type LoginOptions

type LoginOptions struct {
	*GlobalOptions
}

LoginOptions for the login command

func NewLoginOptions

func NewLoginOptions(c util.Settings, e *util.Environment) (*LoginOptions, error)

NewLoginOptions constructor

type LogoutOptions

type LogoutOptions struct {
	*GlobalOptions
}

LogoutOptions for the login command

func NewLogoutOptions

func NewLogoutOptions(c util.Settings, e *util.Environment) (*LogoutOptions, error)

NewLogoutOptions constructor

type LogsArgs

type LogsArgs struct {
	Build   Pipeline
	Options *PipelineOptions
	Order   int
	Step    Step
	Logs    string
	Stream  string
	Hidden  bool
}

LogsArgs contains the args associated with the "Logs" event.

type NormalizedEmitter

type NormalizedEmitter struct {
	*emission.Emitter
	// contains filtered or unexported fields
}

NormalizedEmitter wraps the emission.Emitter and is smart enough about our events to fill in details as needed so that we don't need so many args

func EmitterFromContext

func EmitterFromContext(ctx context.Context) (e *NormalizedEmitter, err error)

EmitterFromContext gives us the emitter attached to the context

func NewNormalizedEmitter

func NewNormalizedEmitter() *NormalizedEmitter

NewNormalizedEmitter constructor

func (*NormalizedEmitter) Emit

func (e *NormalizedEmitter) Emit(event interface{}, args interface{})

Emit normalizes our events by storing some state

type Pipeline

type Pipeline interface {
	// Getters
	Env() *util.Environment // base
	Box() Box               // base
	Services() []ServiceBox //base
	Steps() []Step          // base
	AfterSteps() []Step     // base

	// Methods
	CommonEnv() [][]string     // base
	InitEnv(*util.Environment) // impl
	CollectArtifact(string) (*Artifact, error)
	CollectCache(string) error
	LocalSymlink()
	SetupGuest(context.Context, *Session) error
	ExportEnvironment(context.Context, *Session) error
	SyncEnvironment(context.Context, *Session) error

	LogEnvironment()
	DockerRepo() string
	DockerTag() string
	DockerMessage() string
}

Pipeline is a set of steps to run, this is the interface shared by both Build and Deploy

type PipelineConfig

type PipelineConfig struct {
	Box        *RawBoxConfig
	Steps      RawStepsConfig
	AfterSteps RawStepsConfig `yaml:"after-steps"`
	StepsMap   map[string][]*RawStepConfig
	Services   []*RawBoxConfig `yaml:"services"`
	BasePath   string          `yaml:"base-path"`
}

PipelineConfig is for any pipeline sections StepsMap is for compat with the multiple deploy target configs TODO(termie): it would be great to deprecate this behavior and switch

to multiple pipelines instead

type PipelineDefaultsUsed

type PipelineDefaultsUsed struct {
	IgnoreFile bool
}

type PipelineOptions

type PipelineOptions struct {
	*GlobalOptions
	*AWSOptions
	// *DockerOptions
	*GitOptions
	*KeenOptions
	*ReporterOptions

	// TODO(termie): i'd like to remove this, it is only used in a couple
	//               places by BasePipeline
	HostEnv *util.Environment

	RunID        string
	DeployTarget string
	Pipeline     string

	ApplicationID            string
	ApplicationName          string
	ApplicationOwnerName     string
	ApplicationStartedByName string

	WerckerContainerRegistry *url.URL

	ShouldCommit  bool
	Repository    string
	Tag           string
	Message       string
	ShouldStoreS3 bool

	WorkingDir string

	GuestRoot  string
	MntRoot    string
	ReportRoot string
	// will be set by pipeline when it initializes
	PipelineBasePath string

	ProjectID   string
	ProjectURL  string
	ProjectPath string

	CommandTimeout    int
	NoResponseTimeout int
	ShouldArtifacts   bool
	ShouldRemove      bool
	SourceDir         string
	IgnoreFile        string

	AttachOnError  bool
	DirectMount    bool
	EnableDevSteps bool
	PublishPorts   []string
	ExposePorts    bool
	EnableVolumes  bool
	WerckerYml     string
	Checkpoint     string

	DefaultsUsed PipelineDefaultsUsed
}

PipelineOptions for builds and deploys

func EmptyPipelineOptions

func EmptyPipelineOptions() *PipelineOptions

func NewBuildOptions

func NewBuildOptions(c util.Settings, e *util.Environment) (*PipelineOptions, error)

NewBuildOptions constructor

func NewCheckConfigOptions

func NewCheckConfigOptions(c util.Settings, e *util.Environment) (*PipelineOptions, error)

NewCheckConfigOptions constructor

func NewDeployOptions

func NewDeployOptions(c util.Settings, e *util.Environment) (*PipelineOptions, error)

NewDeployOptions constructor

func NewDevOptions

func NewDevOptions(c util.Settings, e *util.Environment) (*PipelineOptions, error)

NewDevOptions ctor

func NewPipelineOptions

func NewPipelineOptions(c util.Settings, e *util.Environment) (*PipelineOptions, error)

NewPipelineOptions big-ass constructor

func (*PipelineOptions) BasePath

func (o *PipelineOptions) BasePath() string

func (*PipelineOptions) BuildPath

func (o *PipelineOptions) BuildPath(s ...string) string

BuildPath returns the path where created builds live

func (*PipelineOptions) CachePath

func (o *PipelineOptions) CachePath() string

CachePath returns the path for storing pipeline cache

func (*PipelineOptions) ContainerPath

func (o *PipelineOptions) ContainerPath() string

ContainerPath returns the path where exported containers live

func (*PipelineOptions) GuestPath

func (o *PipelineOptions) GuestPath(s ...string) string

GuestPath returns a path relative to the build root on the guest.

func (*PipelineOptions) HostPath

func (o *PipelineOptions) HostPath(s ...string) string

HostPath returns a path relative to the build root on the host.

func (*PipelineOptions) IgnoreFilePath

func (o *PipelineOptions) IgnoreFilePath() string

IgnoreFilePath return the absolute path of the ignore file

func (*PipelineOptions) MntPath

func (o *PipelineOptions) MntPath(s ...string) string

MntPath returns a path relative to the read-only mount root on the guest.

func (*PipelineOptions) ProjectDownloadPath

func (o *PipelineOptions) ProjectDownloadPath() string

ProjectDownloadPath returns the path where downloaded projects live

func (*PipelineOptions) ReportPath

func (o *PipelineOptions) ReportPath(s ...string) string

ReportPath returns a path relative to the report root on the guest.

func (*PipelineOptions) SourcePath

func (o *PipelineOptions) SourcePath() string

func (*PipelineOptions) StepPath

func (o *PipelineOptions) StepPath() string

StepPath returns the path where downloaded steps live

func (*PipelineOptions) WorkflowURL

func (o *PipelineOptions) WorkflowURL() string

func (*PipelineOptions) WorkingPath

func (o *PipelineOptions) WorkingPath(s ...string) string

WorkingPath returns paths relative to our working dir (usually ".wercker")

type PipelineResult

type PipelineResult struct {
	Success           bool
	FailedStepName    string
	FailedStepMessage string
}

PipelineResult keeps track of the results of a build or deploy mostly so that we can use it to run after-steps

func (*PipelineResult) ExportEnvironment

func (pr *PipelineResult) ExportEnvironment(sessionCtx context.Context, sess *Session) error

ExportEnvironment for this pipeline result (used in after-steps)

type PullOptions

type PullOptions struct {
	*GlobalOptions

	Repository string
	Branch     string
	Commit     string
	Status     string
	Result     string
	Output     string
	Load       bool
	Force      bool
}

PullOptions for the pull command

func NewPullOptions

func NewPullOptions(c util.Settings, e *util.Environment) (*PullOptions, error)

NewPullOptions constructor

type RawBoxConfig

type RawBoxConfig struct {
	*BoxConfig
}

RawBoxConfig is the unwrapper for BoxConfig

func (*RawBoxConfig) UnmarshalYAML

func (r *RawBoxConfig) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML first attempts to unmarshal as a string to ID otherwise attempts to unmarshal to the whole struct

type RawConfig

type RawConfig struct {
	*Config
}

RawConfig is the unwrapper for Config

func (*RawConfig) IsValid

func (r *RawConfig) IsValid() error

IsValid ensures that the underlying Config is populated properly

func (*RawConfig) UnmarshalYAML

func (r *RawConfig) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML in this case is a little involved due to the myriad shapes our data can take for deploys (unfortunately), so we have to pretend the data is a map for a while and do a marshal/unmarshal hack to parse the subsections

type RawPipelineConfig

type RawPipelineConfig struct {
	*PipelineConfig
}

RawPipelineConfig is our unwrapper for PipelineConfig

func (*RawPipelineConfig) UnmarshalYAML

func (r *RawPipelineConfig) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML in this case is a little involved due to the myriad shapes our data can take for deploys (unfortunately), so we have to pretend the data is a map for a while and do a marshal/unmarshal hack to parse the subsections

type RawStepConfig

type RawStepConfig struct {
	*StepConfig
}

RawStepConfig is our unwrapper for config steps

func (*RawStepConfig) UnmarshalYAML

func (r *RawStepConfig) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML is fun, for this one as we're supporting three different types of yaml structures, a string, a map[string]map[string]string, and a map[string]string, these basically equate to these three styles of specifying the step that people commonly use:

steps:
 - string-step  # this parses as a string
 - script:      # this parses as a map[string]map[string]string
     code: done right
 - script:      # this parses as a map[string]string
   code: done wrong

type RawStepsConfig

type RawStepsConfig []*RawStepConfig

RawStepsConfig is a list of RawStepConfigs

type Receiver

type Receiver struct {
	// contains filtered or unexported fields
}

Receiver is for reading from our session

func NewReceiver

func NewReceiver(queue chan string) *Receiver

NewReceiver returns a new channel-based io.Writer

func (*Receiver) Write

func (r *Receiver) Write(p []byte) (int, error)

Write writes to a channel

type ReporterOptions

type ReporterOptions struct {
	*GlobalOptions
	ReporterHost string
	ReporterKey  string
	ShouldReport bool
}

ReporterOptions for our reporting

func NewReporterOptions

func NewReporterOptions(c util.Settings, e *util.Environment, globalOpts *GlobalOptions) (*ReporterOptions, error)

NewReporterOptions constructor

type S3Store

type S3Store struct {
	// contains filtered or unexported fields
}

S3Store stores files in S3

func NewS3Store

func NewS3Store(options *AWSOptions) *S3Store

NewS3Store creates a new S3Store

func (*S3Store) StoreFromFile

func (s *S3Store) StoreFromFile(args *StoreFromFileArgs) error

StoreFromFile copies the file from args.Path to options.Bucket + args.Key.

type Sender

type Sender struct {
	// contains filtered or unexported fields
}

Sender is for sending to our session

func NewSender

func NewSender(queue chan string) *Sender

NewSender gives us a new channel-based io.Reader

func (*Sender) Read

func (s *Sender) Read(p []byte) (int, error)

Read reads from a channel

type ServiceBox

type ServiceBox interface {
	Run(context.Context, *util.Environment, []string) (*docker.Container, error)
	Fetch(ctx context.Context, env *util.Environment) (*docker.Image, error)
	Link() string
	GetID() string
	GetName() string
}

ServiceBox interface to services

type Session

type Session struct {
	// contains filtered or unexported fields
}

Session is our way to interact with the docker container

func NewSession

func NewSession(options *PipelineOptions, transport Transport) *Session

NewSession returns a new interactive session to a container.

func (*Session) Attach

func (s *Session) Attach(runnerCtx context.Context) (context.Context, error)

Attach us to our container and set up read and write queues. Returns a context object for the transport so we can propagate cancels on errors and closed connections.

func (*Session) HideLogs

func (s *Session) HideLogs()

HideLogs will emit Logs with args.Hidden set to true

func (*Session) Recv

func (s *Session) Recv() chan string

func (*Session) Send

func (s *Session) Send(sessionCtx context.Context, forceHidden bool, commands ...string) error

Send an array of commands.

func (*Session) SendChecked

func (s *Session) SendChecked(sessionCtx context.Context, commands ...string) (int, []string, error)

SendChecked sends commands, waits for them to complete and returns the exit status and output Ways to know a command is done:

[x] We received the sentinel echo
[x] The container has exited and we've exhausted the incoming data
[x] The session has closed and we've exhaused the incoming data
[x] The command has timed out

Ways for a command to be successful:

[x] We received the sentinel echo with exit code 0

func (*Session) ShowLogs

func (s *Session) ShowLogs()

ShowLogs will emit Logs with args.Hidden set to false

func (*Session) Transport

func (s *Session) Transport() interface{}

type Step

type Step interface {
	// Bunch of getters
	DisplayName() string
	Env() *util.Environment
	Cwd() string
	ID() string
	Name() string
	Owner() string
	SafeID() string
	Version() string
	ShouldSyncEnv() bool
	Checkpoint() string

	// Actual methods
	Fetch() (string, error)

	InitEnv(*util.Environment)
	Execute(context.Context, *Session) (int, error)
	CollectFile(string, string, string, io.Writer) error
	CollectArtifact(string) (*Artifact, error)
	// TODO(termie): don't think this needs to be universal
	ReportPath(...string) string
}

Step interface for steps, to be renamed

type StepConfig

type StepConfig struct {
	ID         string
	Cwd        string
	Name       string
	Data       map[string]string
	Checkpoint string
}

StepConfig holds our step configs

type StepDesc

type StepDesc struct {
	Name        string
	Version     string
	Description string
	Keywords    []string
	Properties  map[string]StepDescProperty
}

StepDesc represents a wercker-step.yml

func ReadStepDesc

func ReadStepDesc(descPath string) (*StepDesc, error)

ReadStepDesc reads a file, expecting it to be parsed into a StepDesc.

func (*StepDesc) Defaults

func (sc *StepDesc) Defaults() map[string]string

Defaults returns the default properties for a step as a map.

type StepDescProperty

type StepDescProperty struct {
	Default  string
	Required bool
	Type     string
}

StepDescProperty is the structure of the values in the "properties" section of the config

type Store

type Store interface {
	// StoreFromFile copies a file from local disk to the store
	StoreFromFile(*StoreFromFileArgs) error
}

Store is generic store interface

type StoreFromFileArgs

type StoreFromFileArgs struct {
	// Path to the local file.
	Path string

	// Key of the file as stored in the store.
	Key string

	// ContentType hints to the content-type of the file (might be ignored)
	ContentType string

	// Meta data associated with the upload (might be ignored)
	Meta map[string]*string

	// MaxTries is the maximum that a store should retry should the store fail.
	MaxTries int
}

StoreFromFileArgs are the args for storing a file

type Transport

type Transport interface {
	Attach(context.Context, io.Reader, io.Writer, io.Writer) (context.Context, error)
}

Transport interface for talking to containervisors

type VersionOptions

type VersionOptions struct {
	OutputJSON     bool
	BetaChannel    bool
	CheckForUpdate bool
}

VersionOptions contains the options associated with the version command.

func NewVersionOptions

func NewVersionOptions(c util.Settings, e *util.Environment) (*VersionOptions, error)

NewVersionOptions constructor

Jump to

Keyboard shortcuts

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