common

package
v9.5.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2017 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PullPolicyAlways       = "always"
	PullPolicyNever        = "never"
	PullPolicyIfNotPresent = "if-not-present"
)
View Source
const AfterScriptTimeout = 5 * time.Minute
View Source
const CheckInterval = 3 * time.Second
View Source
const DefaultArtifactDownloadAttempts = 1
View Source
const DefaultCacheRequestTimeout = 10
View Source
const DefaultExecTimeout = 1800
View Source
const DefaultGetSourcesAttempts = 1
View Source
const DefaultMetricsServerPort = 9252
View Source
const DefaultNetworkClientTimeout = 60 * time.Minute
View Source
const DefaultOutputLimit = 4096 // 4MB in kilobytes
View Source
const DefaultRestoreCacheAttempts = 1
View Source
const DefaultTimeout = 7200
View Source
const DefaultWaitForServicesTimeout = 30
View Source
const ForceTraceSentInterval = 30 * time.Second
View Source
const HealthCheckInterval = 3600
View Source
const HealthyChecks = 3
View Source
const KubernetesPollInterval = 3
View Source
const KubernetesPollTimeout = 180
View Source
const NotHealthyCheckInterval = 300
View Source
const PreparationRetries = 3
View Source
const ReloadConfigInterval = 3
View Source
const ShutdownTimeout = 30
View Source
const UpdateInterval = 3 * time.Second
View Source
const UpdateRetryInterval = 3 * time.Second

Variables

View Source
var BRANCH = "HEAD"
View Source
var BUILT = "now"
View Source
var NAME = "gitlab-ci-multi-runner"
View Source
var PreparationRetryInterval = 3 * time.Second
View Source
var REVISION = "HEAD"
View Source
var VERSION = "dev"

Functions

func GenerateShellScript

func GenerateShellScript(buildStage BuildStage, info ShellScriptInfo) (string, error)

func GetCommands

func GetCommands() []cli.Command

func GetDefaultShell

func GetDefaultShell() string

func GetExecutors

func GetExecutors() []string

func GetShells

func GetShells() []string

func RegisterCommand

func RegisterCommand(command cli.Command)

func RegisterCommand2

func RegisterCommand2(name, usage string, data Commander, flags ...cli.Flag)

func RegisterExecutor

func RegisterExecutor(executor string, provider ExecutorProvider)

func RegisterShell

func RegisterShell(shell Shell)

Types

type AppVersionInfo added in v1.4.0

type AppVersionInfo struct {
	Name         string    `json:"name"`
	Version      string    `json:"version"`
	Revision     string    `json:"revision"`
	Branch       string    `json:"branch"`
	GOVersion    string    `json:"go_version"`
	BuiltAt      time.Time `json:"built_at"`
	OS           string    `json:"os"`
	Architecture string    `json:"architecture"`
}
var AppVersion AppVersionInfo

func (*AppVersionInfo) Extended added in v1.4.0

func (v *AppVersionInfo) Extended() string

func (*AppVersionInfo) Line added in v1.4.0

func (v *AppVersionInfo) Line() string

func (*AppVersionInfo) NewMetricsCollector added in v1.8.0

func (v *AppVersionInfo) NewMetricsCollector() *prometheus.GaugeVec

NewMetricsCollector returns a prometheus.Collector which represents current build information.

func (*AppVersionInfo) Printer added in v1.4.0

func (v *AppVersionInfo) Printer(c *cli.Context)

func (*AppVersionInfo) ShortLine added in v1.4.0

func (v *AppVersionInfo) ShortLine() string

func (*AppVersionInfo) UserAgent added in v1.4.0

func (v *AppVersionInfo) UserAgent() string

type Artifact

type Artifact struct {
	Name      string        `json:"name"`
	Untracked bool          `json:"untracked"`
	Paths     ArtifactPaths `json:"paths"`
	When      ArtifactWhen  `json:"when"`
	ExpireIn  string        `json:"expire_in"`
}

func (Artifact) ShouldUpload

func (a Artifact) ShouldUpload(state error) bool

type ArtifactPaths

type ArtifactPaths []string

type ArtifactWhen

type ArtifactWhen string
const (
	ArtifactWhenOnFailure ArtifactWhen = "on_failure"
	ArtifactWhenOnSuccess ArtifactWhen = "on_success"
	ArtifactWhenAlways    ArtifactWhen = "always"
)

func (ArtifactWhen) OnFailure

func (when ArtifactWhen) OnFailure() bool

func (ArtifactWhen) OnSuccess

func (when ArtifactWhen) OnSuccess() bool

type Artifacts

type Artifacts []Artifact

type Build

type Build struct {
	JobResponse `yaml:",inline"`

	SystemInterrupt chan os.Signal `json:"-" yaml:"-"`
	RootDir         string         `json:"-" yaml:"-"`
	BuildDir        string         `json:"-" yaml:"-"`
	CacheDir        string         `json:"-" yaml:"-"`
	Hostname        string         `json:"-" yaml:"-"`
	Runner          *RunnerConfig  `json:"runner"`
	ExecutorData    ExecutorData

	// Unique ID for all running builds on this runner
	RunnerID int `json:"runner_id"`

	// Unique ID for all running builds on this runner and this project
	ProjectRunnerID int `json:"project_runner_id"`

	CurrentStage BuildStage
	CurrentState BuildRuntimeState
	// contains filtered or unexported fields
}

func (*Build) CurrentExecutorStage

func (b *Build) CurrentExecutorStage() ExecutorStage

func (*Build) FullProjectDir

func (b *Build) FullProjectDir() string

func (*Build) GetAllVariables

func (b *Build) GetAllVariables() (variables JobVariables)

func (*Build) GetBuildTimeout

func (b *Build) GetBuildTimeout() time.Duration

func (*Build) GetCITLSVariables

func (b *Build) GetCITLSVariables() JobVariables

func (*Build) GetCacheRequestTimeout

func (b *Build) GetCacheRequestTimeout() int

func (*Build) GetDefaultVariables

func (b *Build) GetDefaultVariables() JobVariables

func (*Build) GetDockerAuthConfig added in v1.8.0

func (b *Build) GetDockerAuthConfig() string

func (*Build) GetDownloadArtifactsAttempts added in v1.9.0

func (b *Build) GetDownloadArtifactsAttempts() int

func (*Build) GetGetSourcesAttempts added in v1.9.0

func (b *Build) GetGetSourcesAttempts() int

func (*Build) GetGitCheckout

func (b *Build) GetGitCheckout() bool

func (*Build) GetGitDepth added in v1.3.0

func (b *Build) GetGitDepth() string

func (*Build) GetGitStrategy added in v1.3.0

func (b *Build) GetGitStrategy() GitStrategy

func (*Build) GetGitTLSVariables

func (b *Build) GetGitTLSVariables() JobVariables

func (*Build) GetRestoreCacheAttempts added in v1.9.0

func (b *Build) GetRestoreCacheAttempts() int

func (*Build) GetSubmoduleStrategy added in v1.10.0

func (b *Build) GetSubmoduleStrategy() SubmoduleStrategy

func (*Build) IsDebugTraceEnabled added in v1.7.0

func (b *Build) IsDebugTraceEnabled() bool

func (*Build) Log added in v1.3.0

func (b *Build) Log() *logrus.Entry

func (*Build) ProjectSlug

func (b *Build) ProjectSlug() (string, error)

func (*Build) ProjectUniqueDir

func (b *Build) ProjectUniqueDir(sharedDir bool) string

func (*Build) ProjectUniqueName

func (b *Build) ProjectUniqueName() string

func (*Build) Run

func (b *Build) Run(globalConfig *Config, trace JobTrace) (err error)

func (*Build) StartBuild

func (b *Build) StartBuild(rootDir, cacheDir string, sharedDir bool)

func (*Build) String

func (b *Build) String() string

type BuildError added in v1.4.0

type BuildError struct {
	Inner error
}

func (*BuildError) Error added in v1.4.0

func (b *BuildError) Error() string

type BuildLogger added in v1.4.0

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

func NewBuildLogger added in v1.4.0

func NewBuildLogger(log JobTrace, entry *logrus.Entry) BuildLogger

func (*BuildLogger) Debugln added in v1.4.0

func (e *BuildLogger) Debugln(args ...interface{})

func (*BuildLogger) Errorln added in v1.4.0

func (e *BuildLogger) Errorln(args ...interface{})

func (*BuildLogger) Infoln added in v1.4.0

func (e *BuildLogger) Infoln(args ...interface{})

func (*BuildLogger) Println added in v1.4.0

func (e *BuildLogger) Println(args ...interface{})

func (*BuildLogger) SoftErrorln added in v1.4.0

func (e *BuildLogger) SoftErrorln(args ...interface{})

func (*BuildLogger) Warningln added in v1.4.0

func (e *BuildLogger) Warningln(args ...interface{})

type BuildRuntimeState added in v1.9.0

type BuildRuntimeState string
const (
	BuildRunStatePending      BuildRuntimeState = "pending"
	BuildRunRuntimeRunning    BuildRuntimeState = "running"
	BuildRunRuntimeFinished   BuildRuntimeState = "finished"
	BuildRunRuntimeCanceled   BuildRuntimeState = "canceled"
	BuildRunRuntimeTerminated BuildRuntimeState = "terminated"
	BuildRunRuntimeTimedout   BuildRuntimeState = "timedout"
)

type BuildStage added in v1.9.0

type BuildStage string
const (
	BuildStagePrepare           BuildStage = "prepare_script"
	BuildStageGetSources        BuildStage = "get_sources"
	BuildStageRestoreCache      BuildStage = "restore_cache"
	BuildStageDownloadArtifacts BuildStage = "download_artifacts"
	BuildStageUserScript        BuildStage = "build_script"
	BuildStageAfterScript       BuildStage = "after_script"
	BuildStageArchiveCache      BuildStage = "archive_cache"
	BuildStageUploadArtifacts   BuildStage = "upload_artifacts"
)

type Cache

type Cache struct {
	Key       string        `json:"key"`
	Untracked bool          `json:"untracked"`
	Policy    CachePolicy   `json:"policy"`
	Paths     ArtifactPaths `json:"paths"`
}

func (Cache) CheckPolicy

func (c Cache) CheckPolicy(wanted CachePolicy) (bool, error)

type CacheConfig

type CacheConfig struct {
	Type           string `toml:"Type,omitempty" long:"type" env:"CACHE_TYPE" description:"Select caching method: s3, to use S3 buckets"`
	ServerAddress  string `` /* 138-byte string literal not displayed */
	AccessKey      string `toml:"AccessKey,omitempty" long:"s3-access-key" env:"S3_ACCESS_KEY" description:"S3 Access Key"`
	SecretKey      string `toml:"SecretKey,omitempty" long:"s3-secret-key" env:"S3_SECRET_KEY" description:"S3 Secret Key"`
	BucketName     string `` /* 130-byte string literal not displayed */
	BucketLocation string `toml:"BucketLocation,omitempty" long:"s3-bucket-location" env:"S3_BUCKET_LOCATION" description:"Name of S3 region"`
	Insecure       bool   `toml:"Insecure,omitempty" long:"s3-insecure" env:"S3_CACHE_INSECURE" description:"Use insecure mode (without https)"`
	Path           string `toml:"Path,omitempty" long:"s3-cache-path" env:"S3_CACHE_PATH" description:"Name of the path to prepend to the cache URL"`
	Shared         bool   `toml:"Shared,omitempty" long:"cache-shared" env:"CACHE_SHARED" description:"Enable cache sharing between runners."`
}

type CachePolicy

type CachePolicy string
const (
	CachePolicyUndefined CachePolicy = ""
	CachePolicyPullPush  CachePolicy = "pull-push"
	CachePolicyPull      CachePolicy = "pull"
	CachePolicyPush      CachePolicy = "push"
)

type Caches

type Caches []Cache

type Commander

type Commander interface {
	Execute(c *cli.Context)
}

type Config

type Config struct {
	MetricsServerAddress string          `toml:"metrics_server,omitempty" json:"metrics_server"`
	Concurrent           int             `toml:"concurrent" json:"concurrent"`
	CheckInterval        int             `toml:"check_interval" json:"check_interval" description:"Define active checking interval of jobs"`
	LogLevel             *string         `toml:"log_level" json:"log_level" description:"Define log level (one of: panic, fatal, error, warning, info, debug)"`
	User                 string          `toml:"user,omitempty" json:"user"`
	Runners              []*RunnerConfig `toml:"runners" json:"runners"`
	SentryDSN            *string         `toml:"sentry_dsn"`
	ModTime              time.Time       `toml:"-"`
	Loaded               bool            `toml:"-"`
}

func NewConfig

func NewConfig() *Config

func (*Config) GetCheckInterval added in v1.3.0

func (c *Config) GetCheckInterval() time.Duration

func (*Config) LoadConfig

func (c *Config) LoadConfig(configFile string) error

func (*Config) SaveConfig

func (c *Config) SaveConfig(configFile string) error

func (*Config) StatConfig

func (c *Config) StatConfig(configFile string) error

type Credentials

type Credentials struct {
	Type     string `json:"type"`
	URL      string `json:"url"`
	Username string `json:"username"`
	Password string `json:"password"`
}

type Dependencies

type Dependencies []Dependency

type Dependency

type Dependency struct {
	ID            int                     `json:"id"`
	Token         string                  `json:"token"`
	Name          string                  `json:"name"`
	ArtifactsFile DependencyArtifactsFile `json:"artifacts_file"`
}

type DependencyArtifactsFile

type DependencyArtifactsFile struct {
	Filename string `json:"filename"`
	Size     int64  `json:"size"`
}

type DockerConfig

type DockerConfig struct {
	docker_helpers.DockerCredentials
	Hostname               string            `toml:"hostname,omitempty" json:"hostname" long:"hostname" env:"DOCKER_HOSTNAME" description:"Custom container hostname"`
	Image                  string            `toml:"image" json:"image" long:"image" env:"DOCKER_IMAGE" description:"Docker image to be used"`
	CPUSetCPUs             string            `` /* 159-byte string literal not displayed */
	CPUS                   string            `toml:"cpus,omitempty" json:"cpus" long:"cpus" env:"DOCKER_CPUS" description:"Number of CPUs"`
	DNS                    []string          `toml:"dns,omitempty" json:"dns" long:"dns" env:"DOCKER_DNS" description:"A list of DNS servers for the container to use"`
	DNSSearch              []string          `` /* 130-byte string literal not displayed */
	Privileged             bool              `` /* 138-byte string literal not displayed */
	UsernsMode             string            `toml:"userns_mode,omitempty" json:"userns_mode" long:"userns" env:"DOCKER_USERNS_MODE" description:"User namespace to use"`
	CapAdd                 []string          `toml:"cap_add" json:"cap_add" long:"cap-add" env:"DOCKER_CAP_ADD" description:"Add Linux capabilities"`
	CapDrop                []string          `toml:"cap_drop" json:"cap_drop" long:"cap-drop" env:"DOCKER_CAP_DROP" description:"Drop Linux capabilities"`
	SecurityOpt            []string          `toml:"security_opt" json:"security_opt" long:"security-opt" env:"DOCKER_SECURITY_OPT" description:"Security Options"`
	Devices                []string          `toml:"devices" json:"devices" long:"devices" env:"DOCKER_DEVICES" description:"Add a host device to the container"`
	DisableCache           bool              `` /* 142-byte string literal not displayed */
	Volumes                []string          `toml:"volumes,omitempty" json:"volumes" long:"volumes" env:"DOCKER_VOLUMES" description:"Bind mount a volumes"`
	VolumeDriver           string            `` /* 138-byte string literal not displayed */
	CacheDir               string            `` /* 129-byte string literal not displayed */
	ExtraHosts             []string          `` /* 137-byte string literal not displayed */
	VolumesFrom            []string          `` /* 161-byte string literal not displayed */
	NetworkMode            string            `` /* 143-byte string literal not displayed */
	Links                  []string          `toml:"links,omitempty" json:"links" long:"links" env:"DOCKER_LINKS" description:"Add link to another container"`
	Services               []string          `` /* 136-byte string literal not displayed */
	WaitForServicesTimeout int               `` /* 197-byte string literal not displayed */
	AllowedImages          []string          `` /* 142-byte string literal not displayed */
	AllowedServices        []string          `` /* 152-byte string literal not displayed */
	PullPolicy             DockerPullPolicy  `` /* 154-byte string literal not displayed */
	ShmSize                int64             `` /* 141-byte string literal not displayed */
	Tmpfs                  map[string]string `` /* 353-byte string literal not displayed */
	ServicesTmpfs          map[string]string `` /* 388-byte string literal not displayed */
	SysCtls                DockerSysCtls     `` /* 178-byte string literal not displayed */
}

func (*DockerConfig) GetNanoCPUs

func (c *DockerConfig) GetNanoCPUs() (int64, error)

type DockerMachine

type DockerMachine struct {
	IdleCount      int      `long:"idle-nodes" env:"MACHINE_IDLE_COUNT" description:"Maximum idle machines"`
	IdleTime       int      `toml:"IdleTime,omitzero" long:"idle-time" env:"MACHINE_IDLE_TIME" description:"Minimum time after node can be destroyed"`
	MaxBuilds      int      `` /* 128-byte string literal not displayed */
	MachineDriver  string   `long:"machine-driver" env:"MACHINE_DRIVER" description:"The driver to use when creating machine"`
	MachineName    string   `long:"machine-name" env:"MACHINE_NAME" description:"The template for machine name (needs to include %s)"`
	MachineOptions []string `long:"machine-options" env:"MACHINE_OPTIONS" description:"Additional machine creation options"`

	OffPeakPeriods   []string `long:"off-peak-periods" env:"MACHINE_OFF_PEAK_PERIODS" description:"Time periods when the scheduler is in the OffPeak mode"`
	OffPeakTimezone  string   `long:"off-peak-timezone" env:"MACHINE_OFF_PEAK_TIMEZONE" description:"Timezone for the OffPeak periods (defaults to Local)"`
	OffPeakIdleCount int      `` /* 138-byte string literal not displayed */
	OffPeakIdleTime  int      `` /* 158-byte string literal not displayed */
	// contains filtered or unexported fields
}

func (*DockerMachine) CompileOffPeakPeriods added in v1.7.0

func (c *DockerMachine) CompileOffPeakPeriods() (err error)

func (*DockerMachine) GetIdleCount added in v1.7.0

func (c *DockerMachine) GetIdleCount() int

func (*DockerMachine) GetIdleTime added in v1.7.0

func (c *DockerMachine) GetIdleTime() int

type DockerPullPolicy

type DockerPullPolicy string

func (DockerPullPolicy) Get

Get returns one of the predefined values or returns an error if the value can't match the predefined

type DockerSysCtls

type DockerSysCtls map[string]string

type DownloadState

type DownloadState int
const (
	DownloadSucceeded DownloadState = iota
	DownloadForbidden
	DownloadFailed
	DownloadNotFound
)

type Executor

type Executor interface {
	Shell() *ShellScriptInfo
	Prepare(options ExecutorPrepareOptions) error
	Run(cmd ExecutorCommand) error
	Finish(err error)
	Cleanup()
	GetCurrentStage() ExecutorStage
	SetCurrentStage(stage ExecutorStage)
}

func NewExecutor

func NewExecutor(executor string) Executor

type ExecutorCommand added in v1.2.0

type ExecutorCommand struct {
	Script     string
	Predefined bool
	Context    context.Context
}

type ExecutorData

type ExecutorData interface{}

type ExecutorPrepareOptions

type ExecutorPrepareOptions struct {
	Config  *RunnerConfig
	Build   *Build
	Trace   JobTrace
	User    string
	Context context.Context
}

type ExecutorProvider

type ExecutorProvider interface {
	CanCreate() bool
	Create() Executor
	Acquire(config *RunnerConfig) (ExecutorData, error)
	Release(config *RunnerConfig, data ExecutorData) error
	GetFeatures(features *FeaturesInfo)
}

func GetExecutor

func GetExecutor(executor string) ExecutorProvider

func GetExecutorProviders added in v1.9.0

func GetExecutorProviders() (providers []ExecutorProvider)

type ExecutorStage

type ExecutorStage string
const (
	ExecutorStageCreated ExecutorStage = "created"
	ExecutorStagePrepare ExecutorStage = "prepare"
	ExecutorStageFinish  ExecutorStage = "finish"
	ExecutorStageCleanup ExecutorStage = "cleanup"
)

type FeaturesInfo

type FeaturesInfo struct {
	Variables bool `json:"variables"`
	Image     bool `json:"image"`
	Services  bool `json:"services"`
	Artifacts bool `json:"features"`
	Cache     bool `json:"cache"`
}

type GitInfo

type GitInfo struct {
	RepoURL   string         `json:"repo_url"`
	Ref       string         `json:"ref"`
	Sha       string         `json:"sha"`
	BeforeSha string         `json:"before_sha"`
	RefType   GitInfoRefType `json:"ref_type"`
}

type GitInfoRefType

type GitInfoRefType string
const (
	RefTypeBranch GitInfoRefType = "branch"
	RefTypeTag    GitInfoRefType = "tag"
)

type GitStrategy added in v1.3.0

type GitStrategy int
const (
	GitClone GitStrategy = iota
	GitFetch
	GitNone
)

type Image

type Image struct {
	Name       string   `json:"name"`
	Alias      string   `json:"alias,omitempty"`
	Command    []string `json:"command,omitempty"`
	Entrypoint []string `json:"entrypoint,omitempty"`
}

type JobCredentials

type JobCredentials struct {
	ID          int    `long:"id" env:"CI_JOB_ID" description:"The build ID to upload artifacts for"`
	Token       string `long:"token" env:"CI_JOB_TOKEN" required:"true" description:"Build token"`
	URL         string `long:"url" env:"CI_SERVER_URL" required:"true" description:"GitLab CI URL"`
	TLSCAFile   string `` /* 129-byte string literal not displayed */
	TLSCertFile string `` /* 141-byte string literal not displayed */
	TLSKeyFile  string `` /* 139-byte string literal not displayed */
}

func (*JobCredentials) GetTLSCAFile

func (j *JobCredentials) GetTLSCAFile() string

func (*JobCredentials) GetTLSCertFile

func (j *JobCredentials) GetTLSCertFile() string

func (*JobCredentials) GetTLSKeyFile

func (j *JobCredentials) GetTLSKeyFile() string

func (*JobCredentials) GetToken

func (j *JobCredentials) GetToken() string

func (*JobCredentials) GetURL

func (j *JobCredentials) GetURL() string

type JobInfo

type JobInfo struct {
	Name        string `json:"name"`
	Stage       string `json:"stage"`
	ProjectID   int    `json:"project_id"`
	ProjectName string `json:"project_name"`
}

type JobRequest

type JobRequest struct {
	Info       VersionInfo `json:"info,omitempty"`
	Token      string      `json:"token,omitempty"`
	LastUpdate string      `json:"last_update,omitempty"`
}

type JobResponse

type JobResponse struct {
	ID            int           `json:"id"`
	Token         string        `json:"token"`
	AllowGitFetch bool          `json:"allow_git_fetch"`
	JobInfo       JobInfo       `json:"job_info"`
	GitInfo       GitInfo       `json:"git_info"`
	RunnerInfo    RunnerInfo    `json:"runner_info"`
	Variables     JobVariables  `json:"variables"`
	Steps         Steps         `json:"steps"`
	Image         Image         `json:"image"`
	Services      Services      `json:"services"`
	Artifacts     Artifacts     `json:"artifacts"`
	Cache         Caches        `json:"cache"`
	Credentials   []Credentials `json:"credentials"`
	Dependencies  Dependencies  `json:"dependencies"`

	TLSCAChain  string `json:"-"`
	TLSAuthCert string `json:"-"`
	TLSAuthKey  string `json:"-"`
}

func GetFailedBuild added in v1.8.0

func GetFailedBuild() (JobResponse, error)

func GetLongRunningBuild added in v1.8.0

func GetLongRunningBuild() (JobResponse, error)

func GetMultilineBashBuild

func GetMultilineBashBuild() (JobResponse, error)

func GetRemoteFailedBuild added in v1.8.0

func GetRemoteFailedBuild() (JobResponse, error)

func GetRemoteLongRunningBuild added in v1.8.0

func GetRemoteLongRunningBuild() (JobResponse, error)

func GetRemoteSuccessfulBuild added in v1.8.0

func GetRemoteSuccessfulBuild() (JobResponse, error)

func GetSuccessfulBuild added in v1.8.0

func GetSuccessfulBuild() (JobResponse, error)

func (*JobResponse) RepoCleanURL

func (j *JobResponse) RepoCleanURL() string

type JobState

type JobState string
const (
	Pending JobState = "pending"
	Running JobState = "running"
	Failed  JobState = "failed"
	Success JobState = "success"
)

type JobTrace

type JobTrace interface {
	io.Writer
	Success()
	Fail(err error)
	SetCancelFunc(cancelFunc context.CancelFunc)
	IsStdout() bool
}

type JobTracePatch

type JobTracePatch interface {
	Patch() []byte
	Offset() int
	Limit() int
	SetNewOffset(newOffset int)
	ValidateRange() bool
}

type JobVariable

type JobVariable struct {
	Key      string `json:"key"`
	Value    string `json:"value"`
	Public   bool   `json:"public"`
	Internal bool   `json:"-"`
	File     bool   `json:"file"`
}

func ParseVariable

func ParseVariable(text string) (variable JobVariable, err error)

func (JobVariable) String

func (b JobVariable) String() string

type JobVariables

type JobVariables []JobVariable

func (JobVariables) Expand

func (b JobVariables) Expand() (variables JobVariables)

func (JobVariables) ExpandValue

func (b JobVariables) ExpandValue(value string) string

func (JobVariables) Get

func (b JobVariables) Get(key string) string

func (JobVariables) PublicOrInternal

func (b JobVariables) PublicOrInternal() (variables JobVariables)

func (JobVariables) StringList

func (b JobVariables) StringList() (variables []string)

type KubernetesConfig added in v1.6.0

type KubernetesConfig struct {
	Host                          string               `` /* 151-byte string literal not displayed */
	CertFile                      string               `` /* 145-byte string literal not displayed */
	KeyFile                       string               `` /* 141-byte string literal not displayed */
	CAFile                        string               `` /* 140-byte string literal not displayed */
	Image                         string               `` /* 137-byte string literal not displayed */
	Namespace                     string               `` /* 127-byte string literal not displayed */
	NamespaceOverwriteAllowed     string               `` /* 220-byte string literal not displayed */
	Privileged                    bool                 `` /* 156-byte string literal not displayed */
	CPULimit                      string               `` /* 146-byte string literal not displayed */
	MemoryLimit                   string               `` /* 164-byte string literal not displayed */
	ServiceCPULimit               string               `` /* 186-byte string literal not displayed */
	ServiceMemoryLimit            string               `` /* 204-byte string literal not displayed */
	HelperCPULimit                string               `` /* 181-byte string literal not displayed */
	HelperMemoryLimit             string               `` /* 199-byte string literal not displayed */
	CPURequest                    string               `` /* 159-byte string literal not displayed */
	MemoryRequest                 string               `` /* 174-byte string literal not displayed */
	ServiceCPURequest             string               `` /* 199-byte string literal not displayed */
	ServiceMemoryRequest          string               `` /* 213-byte string literal not displayed */
	HelperCPURequest              string               `` /* 194-byte string literal not displayed */
	HelperMemoryRequest           string               `` /* 208-byte string literal not displayed */
	PullPolicy                    KubernetesPullPolicy `` /* 231-byte string literal not displayed */
	NodeSelector                  map[string]string    `` /* 239-byte string literal not displayed */
	ImagePullSecrets              []string             `` /* 205-byte string literal not displayed */
	HelperImage                   string               `` /* 199-byte string literal not displayed */
	TerminationGracePeriodSeconds int64                `` /* 330-byte string literal not displayed */
	PollInterval                  int                  `` /* 224-byte string literal not displayed */
	PollTimeout                   int                  `` /* 325-byte string literal not displayed */

	PodLabels                      map[string]string `` /* 268-byte string literal not displayed */
	ServiceAccount                 string            `` /* 195-byte string literal not displayed */
	ServiceAccountOverwriteAllowed string            `` /* 240-byte string literal not displayed */

	Volumes KubernetesVolumes `toml:"volumes"`
}

func (*KubernetesConfig) GetHelperImage added in v1.9.0

func (c *KubernetesConfig) GetHelperImage() string

func (*KubernetesConfig) GetPollAttempts added in v1.10.0

func (c *KubernetesConfig) GetPollAttempts() int

func (*KubernetesConfig) GetPollInterval added in v1.10.0

func (c *KubernetesConfig) GetPollInterval() int

type KubernetesConfigMap

type KubernetesConfigMap struct {
	Name      string            `toml:"name" json:"name" description:"The name of the volume and ConfigMap to use"`
	MountPath string            `toml:"mount_path" description:"Path where volume should be mounted inside of container"`
	ReadOnly  bool              `toml:"read_only,omitempty" description:"If this volume should be mounted read only"`
	Items     map[string]string `toml:"items,omitempty" description:"Key-to-path mapping for keys from the config map that should be used."`
}

type KubernetesHostPath

type KubernetesHostPath struct {
	Name      string `toml:"name" json:"name" description:"The name of the volume"`
	MountPath string `toml:"mount_path" description:"Path where volume should be mounted inside of container"`
	ReadOnly  bool   `toml:"read_only,omitempty" description:"If this volume should be mounted read only"`
	HostPath  string `toml:"host_path,omitempty" description:"Path from the host that should be mounted as a volume"`
}

type KubernetesPVC

type KubernetesPVC struct {
	Name      string `toml:"name" json:"name" description:"The name of the volume and PVC to use"`
	MountPath string `toml:"mount_path" description:"Path where volume should be mounted inside of container"`
	ReadOnly  bool   `toml:"read_only,omitempty" description:"If this volume should be mounted read only"`
}

type KubernetesPullPolicy added in v1.8.0

type KubernetesPullPolicy string

func (KubernetesPullPolicy) Get added in v1.8.0

Get returns one of the predefined values in kubernetes notation or returns an error if the value can't match the predefined

type KubernetesSecret

type KubernetesSecret struct {
	Name      string            `toml:"name" json:"name" description:"The name of the volume and Secret to use"`
	MountPath string            `toml:"mount_path" description:"Path where volume should be mounted inside of container"`
	ReadOnly  bool              `toml:"read_only,omitempty" description:"If this volume should be mounted read only"`
	Items     map[string]string `toml:"items,omitempty" description:"Key-to-path mapping for keys from the secret that should be used."`
}

type KubernetesVolumes

type KubernetesVolumes struct {
	HostPaths  []KubernetesHostPath  `toml:"host_path" description:"The host paths which will be mounted"`
	PVCs       []KubernetesPVC       `toml:"pvc" description:"The persistent volume claims that will be mounted"`
	ConfigMaps []KubernetesConfigMap `toml:"config_map" description:"The config maps which will be mounted as volumes"`
	Secrets    []KubernetesSecret    `toml:"secret" description:"The secret maps which will be mounted"`
}

type MockCommander added in v1.5.0

type MockCommander struct {
	mock.Mock
}

func (*MockCommander) Execute added in v1.5.0

func (m *MockCommander) Execute(c *cli.Context)

type MockExecutor added in v1.5.0

type MockExecutor struct {
	mock.Mock
}

func (*MockExecutor) Cleanup added in v1.5.0

func (m *MockExecutor) Cleanup()

func (*MockExecutor) Finish added in v1.5.0

func (m *MockExecutor) Finish(err error)

func (*MockExecutor) GetCurrentStage

func (m *MockExecutor) GetCurrentStage() ExecutorStage

func (*MockExecutor) Prepare added in v1.5.0

func (m *MockExecutor) Prepare(options ExecutorPrepareOptions) error

func (*MockExecutor) Run added in v1.5.0

func (m *MockExecutor) Run(cmd ExecutorCommand) error

func (*MockExecutor) SetCurrentStage

func (m *MockExecutor) SetCurrentStage(stage ExecutorStage)

func (*MockExecutor) Shell added in v1.5.0

func (m *MockExecutor) Shell() *ShellScriptInfo

type MockExecutorData added in v1.5.0

type MockExecutorData struct {
	mock.Mock
}

type MockExecutorProvider added in v1.5.0

type MockExecutorProvider struct {
	mock.Mock
}

func (*MockExecutorProvider) Acquire added in v1.5.0

func (m *MockExecutorProvider) Acquire(config *RunnerConfig) (ExecutorData, error)

func (*MockExecutorProvider) CanCreate added in v1.5.0

func (m *MockExecutorProvider) CanCreate() bool

func (*MockExecutorProvider) Create added in v1.5.0

func (m *MockExecutorProvider) Create() Executor

func (*MockExecutorProvider) GetFeatures added in v1.5.0

func (m *MockExecutorProvider) GetFeatures(features *FeaturesInfo)

func (*MockExecutorProvider) Release added in v1.5.0

func (m *MockExecutorProvider) Release(config *RunnerConfig, data ExecutorData) error

type MockJobTrace

type MockJobTrace struct {
	mock.Mock
}

func (*MockJobTrace) Fail

func (m *MockJobTrace) Fail(err error)

func (*MockJobTrace) IsStdout

func (m *MockJobTrace) IsStdout() bool

func (*MockJobTrace) SetCancelFunc

func (m *MockJobTrace) SetCancelFunc(cancelFunc context.CancelFunc)

func (*MockJobTrace) Success

func (m *MockJobTrace) Success()

type MockJobTracePatch

type MockJobTracePatch struct {
	mock.Mock
}

func (*MockJobTracePatch) Limit

func (m *MockJobTracePatch) Limit() int

func (*MockJobTracePatch) Offset

func (m *MockJobTracePatch) Offset() int

func (*MockJobTracePatch) Patch

func (m *MockJobTracePatch) Patch() []byte

func (*MockJobTracePatch) SetNewOffset

func (m *MockJobTracePatch) SetNewOffset(newOffset int)

func (*MockJobTracePatch) ValidateRange

func (m *MockJobTracePatch) ValidateRange() bool

type MockNetwork added in v1.5.0

type MockNetwork struct {
	mock.Mock
}

func (*MockNetwork) DownloadArtifacts added in v1.5.0

func (m *MockNetwork) DownloadArtifacts(config JobCredentials, artifactsFile string) DownloadState

func (*MockNetwork) PatchTrace added in v1.5.0

func (m *MockNetwork) PatchTrace(config RunnerConfig, jobCredentials *JobCredentials, tracePart JobTracePatch) UpdateState

func (*MockNetwork) ProcessJob

func (m *MockNetwork) ProcessJob(config RunnerConfig, buildCredentials *JobCredentials) JobTrace

func (*MockNetwork) RegisterRunner added in v1.5.0

func (m *MockNetwork) RegisterRunner(config RunnerCredentials, description string, tags string, runUntagged bool, locked bool) *RegisterRunnerResponse

func (*MockNetwork) RequestJob

func (m *MockNetwork) RequestJob(config RunnerConfig) (*JobResponse, bool)

func (*MockNetwork) UnregisterRunner

func (m *MockNetwork) UnregisterRunner(config RunnerCredentials) bool

func (*MockNetwork) UpdateJob

func (m *MockNetwork) UpdateJob(config RunnerConfig, jobCredentials *JobCredentials, id int, state JobState, trace *string) UpdateState

func (*MockNetwork) UploadArtifacts added in v1.5.0

func (m *MockNetwork) UploadArtifacts(config JobCredentials, artifactsFile string) UploadState

func (*MockNetwork) UploadRawArtifacts added in v1.5.0

func (m *MockNetwork) UploadRawArtifacts(config JobCredentials, reader io.Reader, baseName string, expireIn string) UploadState

func (*MockNetwork) VerifyRunner added in v1.5.0

func (m *MockNetwork) VerifyRunner(config RunnerCredentials) bool

type MockShell added in v1.5.0

type MockShell struct {
	mock.Mock
}

func (*MockShell) GenerateScript added in v1.5.0

func (m *MockShell) GenerateScript(buildStage BuildStage, info ShellScriptInfo) (string, error)

func (*MockShell) GetConfiguration added in v1.5.0

func (m *MockShell) GetConfiguration(info ShellScriptInfo) (*ShellConfiguration, error)

func (*MockShell) GetFeatures added in v1.5.0

func (m *MockShell) GetFeatures(features *FeaturesInfo)

func (*MockShell) GetName added in v1.5.0

func (m *MockShell) GetName() string

func (*MockShell) IsDefault added in v1.5.0

func (m *MockShell) IsDefault() bool

type Network

type Network interface {
	RegisterRunner(config RunnerCredentials, description, tags string, runUntagged, locked bool) *RegisterRunnerResponse
	VerifyRunner(config RunnerCredentials) bool
	UnregisterRunner(config RunnerCredentials) bool
	RequestJob(config RunnerConfig) (*JobResponse, bool)
	UpdateJob(config RunnerConfig, jobCredentials *JobCredentials, id int, state JobState, trace *string) UpdateState
	PatchTrace(config RunnerConfig, jobCredentials *JobCredentials, tracePart JobTracePatch) UpdateState
	DownloadArtifacts(config JobCredentials, artifactsFile string) DownloadState
	UploadRawArtifacts(config JobCredentials, reader io.Reader, baseName string, expireIn string) UploadState
	UploadArtifacts(config JobCredentials, artifactsFile string) UploadState
	ProcessJob(config RunnerConfig, buildCredentials *JobCredentials) JobTrace
}

type ParallelsConfig

type ParallelsConfig struct {
	BaseName         string `toml:"base_name" json:"base_name" long:"base-name" env:"PARALLELS_BASE_NAME" description:"VM name to be used"`
	TemplateName     string `` /* 142-byte string literal not displayed */
	DisableSnapshots bool   `` /* 174-byte string literal not displayed */
}

type RegisterRunnerRequest

type RegisterRunnerRequest struct {
	Info        VersionInfo `json:"info,omitempty"`
	Token       string      `json:"token,omitempty"`
	Description string      `json:"description,omitempty"`
	Tags        string      `json:"tag_list,omitempty"`
	RunUntagged bool        `json:"run_untagged"`
	Locked      bool        `json:"locked"`
}

type RegisterRunnerResponse

type RegisterRunnerResponse struct {
	Token string `json:"token,omitempty"`
}

type RunnerConfig

type RunnerConfig struct {
	Name               string `toml:"name" json:"name" short:"name" long:"description" env:"RUNNER_NAME" description:"Runner name"`
	Limit              int    `` /* 130-byte string literal not displayed */
	OutputLimit        int    `` /* 126-byte string literal not displayed */
	RequestConcurrency int    `` /* 146-byte string literal not displayed */

	RunnerCredentials
	RunnerSettings
}

func (*RunnerConfig) GetRequestConcurrency added in v1.10.8

func (c *RunnerConfig) GetRequestConcurrency() int

func (*RunnerConfig) GetVariables

func (c *RunnerConfig) GetVariables() JobVariables

func (*RunnerConfig) String

func (c *RunnerConfig) String() string

type RunnerCredentials

type RunnerCredentials struct {
	URL         string `toml:"url" json:"url" short:"u" long:"url" env:"CI_SERVER_URL" required:"true" description:"Runner URL"`
	Token       string `toml:"token" json:"token" short:"t" long:"token" env:"CI_SERVER_TOKEN" required:"true" description:"Runner token"`
	TLSCAFile   string `` /* 177-byte string literal not displayed */
	TLSCertFile string `` /* 181-byte string literal not displayed */
	TLSKeyFile  string `` /* 177-byte string literal not displayed */
}

func (*RunnerCredentials) GetTLSCAFile

func (c *RunnerCredentials) GetTLSCAFile() string

func (*RunnerCredentials) GetTLSCertFile

func (c *RunnerCredentials) GetTLSCertFile() string

func (*RunnerCredentials) GetTLSKeyFile

func (c *RunnerCredentials) GetTLSKeyFile() string

func (*RunnerCredentials) GetToken

func (c *RunnerCredentials) GetToken() string

func (*RunnerCredentials) GetURL

func (c *RunnerCredentials) GetURL() string

func (*RunnerCredentials) Log

func (c *RunnerCredentials) Log() *log.Entry

func (*RunnerCredentials) SameAs

func (c *RunnerCredentials) SameAs(other *RunnerCredentials) bool

func (*RunnerCredentials) ShortDescription

func (c *RunnerCredentials) ShortDescription() string

func (*RunnerCredentials) UniqueID

func (c *RunnerCredentials) UniqueID() string

type RunnerInfo

type RunnerInfo struct {
	Timeout int `json:"timeout"`
}

type RunnerSettings

type RunnerSettings struct {
	Executor  string `` /* 140-byte string literal not displayed */
	BuildsDir string `` /* 135-byte string literal not displayed */
	CacheDir  string `` /* 135-byte string literal not displayed */

	Environment     []string `` /* 148-byte string literal not displayed */
	PreCloneScript  string   `` /* 187-byte string literal not displayed */
	PreBuildScript  string   `` /* 214-byte string literal not displayed */
	PostBuildScript string   `` /* 220-byte string literal not displayed */

	Shell string `toml:"shell,omitempty" json:"shell" long:"shell" env:"RUNNER_SHELL" description:"Select bash, cmd or powershell"`

	SSH        *ssh.Config       `toml:"ssh,omitempty" json:"ssh" group:"ssh executor" namespace:"ssh"`
	Docker     *DockerConfig     `toml:"docker,omitempty" json:"docker" group:"docker executor" namespace:"docker"`
	Parallels  *ParallelsConfig  `toml:"parallels,omitempty" json:"parallels" group:"parallels executor" namespace:"parallels"`
	VirtualBox *VirtualBoxConfig `toml:"virtualbox,omitempty" json:"virtualbox" group:"virtualbox executor" namespace:"virtualbox"`
	Cache      *CacheConfig      `toml:"cache,omitempty" json:"cache" group:"cache configuration" namespace:"cache"`
	Machine    *DockerMachine    `toml:"machine,omitempty" json:"machine" group:"docker machine provider" namespace:"machine"`
	Kubernetes *KubernetesConfig `toml:"kubernetes,omitempty" json:"kubernetes" group:"kubernetes executor" namespace:"kubernetes"`
}

type Services

type Services []Image

type Shell

type Shell interface {
	GetName() string
	GetFeatures(features *FeaturesInfo)
	IsDefault() bool

	GetConfiguration(info ShellScriptInfo) (*ShellConfiguration, error)
	GenerateScript(buildStage BuildStage, info ShellScriptInfo) (string, error)
}

func GetShell

func GetShell(shell string) Shell

type ShellConfiguration added in v1.3.0

type ShellConfiguration struct {
	Environment   []string
	DockerCommand []string
	Command       string
	Arguments     []string
	PassFile      bool
	Extension     string
}

func GetShellConfiguration added in v1.3.0

func GetShellConfiguration(info ShellScriptInfo) (*ShellConfiguration, error)

func (*ShellConfiguration) GetCommandWithArguments added in v1.3.0

func (s *ShellConfiguration) GetCommandWithArguments() []string

func (*ShellConfiguration) String added in v1.3.0

func (s *ShellConfiguration) String() string

type ShellScriptInfo

type ShellScriptInfo struct {
	Shell           string
	Build           *Build
	Type            ShellType
	User            string
	RunnerCommand   string
	PreCloneScript  string
	PreBuildScript  string
	PostBuildScript string
}

type ShellType

type ShellType int
const (
	NormalShell ShellType = iota
	LoginShell
)

type Step

type Step struct {
	Name         StepName   `json:"name"`
	Script       StepScript `json:"script"`
	Timeout      int        `json:"timeout"`
	When         StepWhen   `json:"when"`
	AllowFailure bool       `json:"allow_failure"`
}

type StepName

type StepName string
const (
	StepNameScript      StepName = "script"
	StepNameAfterScript StepName = "after_script"
)

type StepScript

type StepScript []string

type StepWhen

type StepWhen string
const (
	StepWhenOnFailure StepWhen = "on_failure"
	StepWhenOnSuccess StepWhen = "on_success"
	StepWhenAlways    StepWhen = "always"
)

type Steps

type Steps []Step

type SubmoduleStrategy added in v1.10.0

type SubmoduleStrategy int
const (
	SubmoduleInvalid SubmoduleStrategy = iota
	SubmoduleNone
	SubmoduleNormal
	SubmoduleRecursive
)

type Trace added in v1.4.0

type Trace struct {
	Writer     io.Writer
	CancelFunc context.CancelFunc
}

func (*Trace) Fail added in v1.4.0

func (s *Trace) Fail(err error)

func (*Trace) IsStdout added in v1.4.0

func (s *Trace) IsStdout() bool

func (*Trace) SetCancelFunc

func (s *Trace) SetCancelFunc(cancelFunc context.CancelFunc)

func (*Trace) Success added in v1.4.0

func (s *Trace) Success()

func (*Trace) Write added in v1.4.0

func (s *Trace) Write(p []byte) (n int, err error)

type UnregisterRunnerRequest

type UnregisterRunnerRequest struct {
	Token string `json:"token,omitempty"`
}

type UpdateJobRequest

type UpdateJobRequest struct {
	Info  VersionInfo `json:"info,omitempty"`
	Token string      `json:"token,omitempty"`
	State JobState    `json:"state,omitempty"`
	Trace *string     `json:"trace,omitempty"`
}

type UpdateState

type UpdateState int
const (
	UpdateSucceeded UpdateState = iota
	UpdateNotFound
	UpdateAbort
	UpdateFailed
	UpdateRangeMismatch
)

type UploadState

type UploadState int
const (
	UploadSucceeded UploadState = iota
	UploadTooLarge
	UploadForbidden
	UploadFailed
)

type VerifyRunnerRequest

type VerifyRunnerRequest struct {
	Token string `json:"token,omitempty"`
}

type VersionInfo

type VersionInfo struct {
	Name         string       `json:"name,omitempty"`
	Version      string       `json:"version,omitempty"`
	Revision     string       `json:"revision,omitempty"`
	Platform     string       `json:"platform,omitempty"`
	Architecture string       `json:"architecture,omitempty"`
	Executor     string       `json:"executor,omitempty"`
	Features     FeaturesInfo `json:"features"`
}

type VirtualBoxConfig

type VirtualBoxConfig struct {
	BaseName         string `toml:"base_name" json:"base_name" long:"base-name" env:"VIRTUALBOX_BASE_NAME" description:"VM name to be used"`
	BaseSnapshot     string `` /* 165-byte string literal not displayed */
	DisableSnapshots bool   `` /* 175-byte string literal not displayed */
}

Jump to

Keyboard shortcuts

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