Documentation ¶
Index ¶
- Constants
- Variables
- func ApplyAnsiStyle(text string, style ...int) string
- func BuildAnsiStyle(parts ...int) string
- func GetNextFriendlyColor() int
- type BuildInfo
- type ColorStore
- type ExecutionError
- type LocalRunner
- func (r *LocalRunner) ContainerKiller(step Step) func() (int, error)
- func (r *LocalRunner) ContainerLogReader(step Step, follow bool) func() error
- func (r *LocalRunner) ContainerRemover(step Step) func() error
- func (r *LocalRunner) ContainerRunner(step Step, network Network) func() error
- func (r *LocalRunner) Copy() Runner
- func (r *LocalRunner) Exec(args []string) error
- func (r *LocalRunner) ImageBuilder(step Step, pull bool) func() error
- func (r *LocalRunner) ImageExistenceChecker(step Step) func() error
- func (r *LocalRunner) ImagePuller(step Step) func() error
- func (r *LocalRunner) NetworkCreator(network Network) func() error
- func (r *LocalRunner) NetworkRemover(network Network) func() error
- func (r *LocalRunner) Output(args []string) ([]byte, error)
- type Network
- type NoopRunner
- func (r *NoopRunner) ContainerKiller(step Step) func() (int, error)
- func (r *NoopRunner) ContainerLogReader(step Step, follow bool) func() error
- func (r *NoopRunner) ContainerRemover(step Step) func() error
- func (r *NoopRunner) ContainerRunner(step Step, network Network) func() error
- func (r *NoopRunner) Copy() Runner
- func (r *NoopRunner) ImageBuilder(step Step, force bool) func() error
- func (r *NoopRunner) ImageExistenceChecker(step Step) func() error
- func (r *NoopRunner) ImagePuller(step Step) func() error
- func (r *NoopRunner) NetworkCreator(network Network) func() error
- func (r *NoopRunner) NetworkRemover(network Network) func() error
- func (r *NoopRunner) NumCalled(key string) int
- func (r *NoopRunner) NumCalls(key string) int
- type Pipeline
- func (p Pipeline) BuildImages(force bool) error
- func (p Pipeline) Check() error
- func (p *Pipeline) CleanUp(signal os.Signal) error
- func (p Pipeline) CreateNetwork() error
- func (p Pipeline) ExecuteSteps() error
- func (p Pipeline) GetRunnerForMeta(meta ServiceMeta) Runner
- func (p Pipeline) KillContainers(preRun bool) error
- func (p Pipeline) Logs(follow bool) error
- func (p Pipeline) PullImages(force bool) error
- func (p Pipeline) RemoveContainers(preRun bool) error
- func (p Pipeline) RemoveNetwork() error
- func (p Pipeline) RemoveTempDirData() error
- type PipelineDefinition
- type PipelineEnvironment
- type Pipelines
- type PrefixedLogger
- type PrefixedWriter
- type Runner
- type Service
- type ServiceKeepAlive
- type ServiceList
- type ServiceLog
- type ServiceLogHandler
- type ServiceMeta
- type ServiceMetaList
- type ServiceType
- type Step
- type StepList
Constants ¶
const AnsiForegroundColorBlack int = 30
AnsiForegroundColorBlack stores int value for black foreground
const AnsiForegroundColorBlue int = 34
AnsiForegroundColorBlue stores int value for blue foreground
const AnsiForegroundColorCyan int = 36
AnsiForegroundColorCyan stores int value for cyan foreground
const AnsiForegroundColorDarkGray int = 90
AnsiForegroundColorDarkGray stores int value for dark gray foreground
const AnsiForegroundColorGreen int = 32
AnsiForegroundColorGreen stores int value for green foreground
const AnsiForegroundColorLightBlue int = 94
AnsiForegroundColorLightBlue stores int value for light blue foreground
const AnsiForegroundColorLightCyan int = 96
AnsiForegroundColorLightCyan stores int value for light cyan foreground
const AnsiForegroundColorLightGray int = 37
AnsiForegroundColorLightGray stores int value for light gray foreground
const AnsiForegroundColorLightGreen int = 92
AnsiForegroundColorLightGreen stores int value for light green foreground
const AnsiForegroundColorLightMagenta int = 95
AnsiForegroundColorLightMagenta stores int value for light magenta foreground
const AnsiForegroundColorLightRed int = 91
AnsiForegroundColorLightRed stores int value for light red foreground
const AnsiForegroundColorLightYellow int = 93
AnsiForegroundColorLightYellow stores int value for light yellow foreground
const AnsiForegroundColorMagenta int = 35
AnsiForegroundColorMagenta stores int value for magenta foreground
const AnsiForegroundColorRed int = 31
AnsiForegroundColorRed stores int value for red foreground
const AnsiForegroundColorWhite int = 97
AnsiForegroundColorWhite stores int value for white foreground
const AnsiForegroundColorYellow int = 33
AnsiForegroundColorYellow stores int value for yellow foreground
const AnsiStyleBold int = 1
AnsiStyleBold stores int value for bold style
const AnsiStyleDim int = 2
AnsiStyleDim stores int value for dim style
const AnsiStyleItalic int = 3
AnsiStyleItalic stores int value for italic style
const AnsiStyleNormal int = 0
AnsiStyleNormal stores int value for normal style
const AnsiStyleStrikethrough int = 9
AnsiStyleStrikethrough stores int value for strikethrough style
const AnsiStyleUnderline int = 4
AnsiStyleUnderline stores int value for underline style
const DockerCompose string = "docker-compose.yml"
DockerCompose stores the default name of a docker compose file.
const GantryDef string = "gantry.def.yml"
GantryDef stores the default name of a gantry definition.
const GantryEnv string = "gantry.env.yml"
GantryEnv stores the default name of a gantry environment.
const GenericStringFormat string = "\u001b[%sm%s\u001b[0m"
GenericStringFormat provides formatting for a single string enclodes in ANSI formatting tags.
const PrefixedWriterFormat string = "%s\u001b[0m %s\u001b[0m"
PrefixedWriterFormat provides formatting for to space separated strings resetting ANSI formatting after each string.
Variables ¶
var ( // Version of the program Version = "no-version" // Verbose is a global verbosity flag Verbose = false // ShowContainerCommands is a global flag to signal printing of commands run. ShowContainerCommands = false // ProjectName stores the global prefix for networks and containers. ProjectName = "" // ForceWharfer is a global flag to force the usage of wharfer even // if the user could use docker directly. ForceWharfer = false )
Functions ¶
func ApplyAnsiStyle ¶
ApplyAnsiStyle applies ansi integer styles to text
func BuildAnsiStyle ¶
BuildAnsiStyle combines style integers with ;
func GetNextFriendlyColor ¶
func GetNextFriendlyColor() int
GetNextFriendlyColor returns the next friendly color from the global friendlyColors store.
Types ¶
type BuildInfo ¶
type BuildInfo struct { Context string `json:"context"` Dockerfile string `json:"dockerfile"` Args types.StringMap `json:"args"` }
BuildInfo represents the build-keyword in a docker-compse.yml.
type ColorStore ¶
type ColorStore struct {
// contains filtered or unexported fields
}
ColorStore provides a synced looping stylelist.
func NewColorStore ¶
func NewColorStore(colors []int) *ColorStore
NewColorStore creates a ColorStore for the provided list of styles.
func (*ColorStore) NextColor ¶
func (c *ColorStore) NextColor() int
NextColor returns the next color. Loops if list is exhausted.
type ExecutionError ¶ added in v0.5.0
type ExecutionError struct {
// contains filtered or unexported fields
}
ExecutionError is an error which stores an additional exit code.
func (ExecutionError) Error ¶ added in v0.5.0
func (e ExecutionError) Error() string
Error returns the string representation of the error.
func (ExecutionError) ExitCode ¶ added in v0.5.0
func (e ExecutionError) ExitCode() int
ExitCode returns the integer with which the programm shall exit.
type LocalRunner ¶
type LocalRunner struct {
// contains filtered or unexported fields
}
LocalRunner creates functions running on localhost.
func NewLocalRunner ¶
NewLocalRunner returns a LocalRunner using provided defaults.
func (*LocalRunner) ContainerKiller ¶ added in v0.4.0
func (r *LocalRunner) ContainerKiller(step Step) func() (int, error)
ContainerKiller returns a function to kill the container for the given step.
func (*LocalRunner) ContainerLogReader ¶ added in v0.5.0
func (r *LocalRunner) ContainerLogReader(step Step, follow bool) func() error
ContainerLogReader returns a function retrieving all logs for a given step.
func (*LocalRunner) ContainerRemover ¶ added in v0.4.0
func (r *LocalRunner) ContainerRemover(step Step) func() error
ContainerRemover returns a function to remove the container for the given step.
func (*LocalRunner) ContainerRunner ¶ added in v0.4.0
func (r *LocalRunner) ContainerRunner(step Step, network Network) func() error
ContainerRunner returns a function to run the given step.
func (*LocalRunner) Copy ¶ added in v0.4.0
func (r *LocalRunner) Copy() Runner
Copy returns a new Instance with copied values.
func (*LocalRunner) Exec ¶
func (r *LocalRunner) Exec(args []string) error
Exec executes given arguments with the containerExecutable.
func (*LocalRunner) ImageBuilder ¶ added in v0.4.0
func (r *LocalRunner) ImageBuilder(step Step, pull bool) func() error
ImageBuilder returns a function to build the image for the given step.
func (*LocalRunner) ImageExistenceChecker ¶ added in v0.4.0
func (r *LocalRunner) ImageExistenceChecker(step Step) func() error
ImageExistenceChecker returns a function which checks if the image for the given step exists.
func (*LocalRunner) ImagePuller ¶ added in v0.4.0
func (r *LocalRunner) ImagePuller(step Step) func() error
ImagePuller retunrs a function to pull the image for the given step.
func (*LocalRunner) NetworkCreator ¶ added in v0.4.0
func (r *LocalRunner) NetworkCreator(network Network) func() error
NetworkCreator returns a function to create the given network.
func (*LocalRunner) NetworkRemover ¶ added in v0.4.0
func (r *LocalRunner) NetworkRemover(network Network) func() error
NetworkRemover returns a function to remove the given network.
type NoopRunner ¶ added in v0.4.0
type NoopRunner struct {
// contains filtered or unexported fields
}
NoopRunner is a runner that does nothing.
func NewNoopRunner ¶ added in v0.4.0
func NewNoopRunner(silent bool) *NoopRunner
NewNoopRunner returns a NoopRunner.
func (*NoopRunner) ContainerKiller ¶ added in v0.4.0
func (r *NoopRunner) ContainerKiller(step Step) func() (int, error)
ContainerKiller returns a function to kill the container for the given step.
func (*NoopRunner) ContainerLogReader ¶ added in v0.5.0
func (r *NoopRunner) ContainerLogReader(step Step, follow bool) func() error
ContainerLogReader returns a function retrieving all logs for a given step.
func (*NoopRunner) ContainerRemover ¶ added in v0.4.0
func (r *NoopRunner) ContainerRemover(step Step) func() error
ContainerRemover returns a function to remove the container for the given step.
func (*NoopRunner) ContainerRunner ¶ added in v0.4.0
func (r *NoopRunner) ContainerRunner(step Step, network Network) func() error
ContainerRunner returns a function to run the given step.
func (*NoopRunner) Copy ¶ added in v0.4.0
func (r *NoopRunner) Copy() Runner
Copy returns the same instance.
func (*NoopRunner) ImageBuilder ¶ added in v0.4.0
func (r *NoopRunner) ImageBuilder(step Step, force bool) func() error
ImageBuilder returns a function to build the image for the given step.
func (*NoopRunner) ImageExistenceChecker ¶ added in v0.4.0
func (r *NoopRunner) ImageExistenceChecker(step Step) func() error
ImageExistenceChecker returns a function which checks if the image for the given step exists.
func (*NoopRunner) ImagePuller ¶ added in v0.4.0
func (r *NoopRunner) ImagePuller(step Step) func() error
ImagePuller returns a function to pull the image for the given step.
func (*NoopRunner) NetworkCreator ¶ added in v0.4.0
func (r *NoopRunner) NetworkCreator(network Network) func() error
NetworkCreator returns a function to create the given network.
func (*NoopRunner) NetworkRemover ¶ added in v0.4.0
func (r *NoopRunner) NetworkRemover(network Network) func() error
NetworkRemover returns a function to create the given network.
func (*NoopRunner) NumCalled ¶ added in v0.4.0
func (r *NoopRunner) NumCalled(key string) int
NumCalled returns how many functions with the given key were executed.
func (*NoopRunner) NumCalls ¶ added in v0.4.0
func (r *NoopRunner) NumCalls(key string) int
NumCalls returns how many functions with the given key were created.
type Pipeline ¶
type Pipeline struct { Definition *PipelineDefinition Environment *PipelineEnvironment Network Network // contains filtered or unexported fields }
Pipeline stores all definitions and settings regarding a deployment.
func NewPipeline ¶
func NewPipeline(definitionPath, environmentPath string, environment types.StringMap, ignoredSteps types.StringSet, selectedSteps types.StringSet) (*Pipeline, error)
NewPipeline creates a new Pipeline from given files which ignores the existence of steps with names provided in ignoreSteps.
func (Pipeline) BuildImages ¶
BuildImages builds all buildable images of Pipeline p in parallel.
func (Pipeline) CreateNetwork ¶
CreateNetwork creates a network using the NetworkName of the Pipeline p.
func (Pipeline) ExecuteSteps ¶
ExecuteSteps runs all not ignored steps/services in the order defined by there dependencies. Each step/service is run as soon as possible.
func (Pipeline) GetRunnerForMeta ¶ added in v0.4.0
func (p Pipeline) GetRunnerForMeta(meta ServiceMeta) Runner
GetRunnerForMeta selects a suitable runner given a ServiceMeta instance.
func (Pipeline) KillContainers ¶
KillContainers kills all running containers of Pipeline p.
func (Pipeline) PullImages ¶
PullImages pulls all pullable images of Pipeline p in parallel.
func (Pipeline) RemoveContainers ¶
RemoveContainers removes all stopped containers of Pipeline p.
func (Pipeline) RemoveNetwork ¶
RemoveNetwork removes the network of Pipeline p.
func (Pipeline) RemoveTempDirData ¶
RemoveTempDirData deletes all data stored in temporary directories.
type PipelineDefinition ¶
type PipelineDefinition struct { Version string Steps StepList // contains filtered or unexported fields }
PipelineDefinition stores docker-compose services and gantry steps.
func NewPipelineDefinition ¶
func NewPipelineDefinition(path string, env *PipelineEnvironment) (*PipelineDefinition, error)
NewPipelineDefinition generates a pipeline definition from a path and an environment.
func (*PipelineDefinition) Pipelines ¶
func (p *PipelineDefinition) Pipelines() (*Pipelines, error)
Pipelines calculates and verifies dependencies and ordering for steps defined in the PipelineDefinition p.
func (*PipelineDefinition) UnmarshalJSON ¶
func (p *PipelineDefinition) UnmarshalJSON(data []byte) error
UnmarshalJSON loads a PipelineDefinition from json using the pipelineJSON struct.
type PipelineEnvironment ¶
type PipelineEnvironment struct { Version string Substitutions types.StringMap TempDirPath string TempDirNoAutoClean bool Steps ServiceMetaList ProjectName string // contains filtered or unexported fields }
PipelineEnvironment stores additional data for pipelines and steps.
func NewPipelineEnvironment ¶
func NewPipelineEnvironment(path string, substitutions types.StringMap, ignoredSteps types.StringSet, selectedSteps types.StringSet) (*PipelineEnvironment, error)
NewPipelineEnvironment builds a new environment merging the current environment, the environment given by path and the user provided steps to ignore.
func (*PipelineEnvironment) ApplyTo ¶
func (e *PipelineEnvironment) ApplyTo(rawFile []byte) ([]byte, error)
ApplyTo executes the environment template parser on the provided data.
func (*PipelineEnvironment) CleanUp ¶
func (e *PipelineEnvironment) CleanUp(signal os.Signal) error
CleanUp tries to remove all managed temporary files and directories.
func (*PipelineEnvironment) UnmarshalJSON ¶
func (e *PipelineEnvironment) UnmarshalJSON(data []byte) error
UnmarshalJSON loads a PipelineDefinition from json using the pipelineJSON struct.
type Pipelines ¶
type Pipelines [][]Step
Pipelines stores parallel and dependent steps/services.
type PrefixedLogger ¶
type PrefixedLogger struct {
// contains filtered or unexported fields
}
PrefixedLogger is a logger with a prefix.
func NewPrefixedLogger ¶
func NewPrefixedLogger(prefix string, logger *log.Logger) *PrefixedLogger
NewPrefixedLogger creates a PrefixedLogger from a prefix and a logger.
func (*PrefixedLogger) Printf ¶
func (p *PrefixedLogger) Printf(format string, v ...interface{})
Printf format prints to the logger.
func (*PrefixedLogger) Println ¶
func (p *PrefixedLogger) Println(v ...interface{})
Println prints a line to the logger.
type PrefixedWriter ¶
type PrefixedWriter struct {
// contains filtered or unexported fields
}
PrefixedWriter is a writer which prefixes all lines with given prefix.
func NewPrefixedWriter ¶
func NewPrefixedWriter(prefix string, target io.Writer) *PrefixedWriter
NewPrefixedWriter returns a PrefixWriter for given prefix and target.
func (*PrefixedWriter) Output ¶
func (p *PrefixedWriter) Output() error
Output generates lines from the internal buffer and prefixes them.
type Runner ¶
type Runner interface { Copy() Runner ImageBuilder(Step, bool) func() error ImagePuller(Step) func() error ImageExistenceChecker(Step) func() error ContainerKiller(Step) func() (int, error) ContainerRemover(Step) func() error ContainerRunner(Step, Network) func() error ContainerLogReader(Step, bool) func() error NetworkCreator(Network) func() error NetworkRemover(Network) func() error }
Runner represents generic container runners.
type Service ¶
type Service struct { BuildInfo BuildInfo `json:"build"` Command types.StringOrStringSlice `json:"command"` Entrypoint types.StringOrStringSlice `json:"entrypoint"` Image string `json:"image"` Ports []string `json:"ports"` Volumes []string `json:"volumes"` Environment types.StringMap `json:"environment"` DependsOn types.StringSet `json:"depends_on"` Restart string `json:"restart"` Name string Meta ServiceMeta // contains filtered or unexported fields }
Service provides a service definition from docker-compose.
func (Service) ColoredContainerName ¶
ColoredContainerName returns the container name of s with color applied.
func (Service) ColoredName ¶
ColoredName returns the name of s with color applied.
func (Service) ContainerName ¶
ContainerName returns the name for a container of s prefixed with the current project name.
func (Service) ImageName ¶
ImageName returns the name of the image of s. The name of the step is used if non is specified.
func (Service) RawContainerName ¶
RawContainerName returns the name for a container of s.
type ServiceKeepAlive ¶
type ServiceKeepAlive int
ServiceKeepAlive stores the KeepAlive state of the service.
const ( // KeepAliveYes signals that the service will keep running after gantry exits. KeepAliveYes ServiceKeepAlive = iota // KeepAliveNo signals that the service will be killed when gantry stops. KeepAliveNo // KeepAliveReplace signals that the service is killed prior to replacement. KeepAliveReplace )
func (*ServiceKeepAlive) UnmarshalJSON ¶
func (d *ServiceKeepAlive) UnmarshalJSON(b []byte) error
UnmarshalJSON sets ServiceKeepAlive d.
type ServiceList ¶
ServiceList stores docker-compose service definitions as steps.
func (*ServiceList) UnmarshalJSON ¶
func (r *ServiceList) UnmarshalJSON(data []byte) error
UnmarshalJSON sets *r to a copy of data.
type ServiceLog ¶
type ServiceLog struct { Handler ServiceLogHandler `json:"handler"` Path string `json:"path"` // contains filtered or unexported fields }
ServiceLog stores log configuration for an output stream.
func (*ServiceLog) Close ¶
func (l *ServiceLog) Close()
Close closes the output file if one is used.
type ServiceLogHandler ¶
type ServiceLogHandler int
ServiceLogHandler stores the logging configuration of the service.
const ( // LogHandlerStdout signals that the standard location (stdout or stderr) is used. LogHandlerStdout ServiceLogHandler = iota // LogHandlerFile signals that the log shall be stored in a file. LogHandlerFile // LogHandlerBoth signals that the log is printed into a file and to the standard location. LogHandlerBoth // LogHandlerDiscard signals that the log shall be discarded. LogHandlerDiscard )
func (*ServiceLogHandler) UnmarshalJSON ¶
func (d *ServiceLogHandler) UnmarshalJSON(b []byte) error
UnmarshalJSON sets ServiceLogHandler d.
type ServiceMeta ¶
type ServiceMeta struct { KeepAlive ServiceKeepAlive `json:"keep_alive"` Stdout ServiceLog `json:"stdout"` Stderr ServiceLog `json:"stderr"` Type ServiceType ExitCodeOverride int `json:"exit_code_override"` Ignore bool `json:"ignore"` IgnoreFailure bool `json:"ignore_failure"` Selected bool }
ServiceMeta stores all metainformation for a step.
func (*ServiceMeta) Open ¶
func (m *ServiceMeta) Open() error
Open handles output initialisation by setting defaults.
type ServiceMetaList ¶
type ServiceMetaList map[string]ServiceMeta
ServiceMetaList stores ServiceMeta as a map[stepname]Meta.
type ServiceType ¶
type ServiceType int
ServiceType stores the type of the service.
const ( // ServiceTypeService signals a normal docker service. ServiceTypeService ServiceType = iota // ServiceTypeStep signals a gantry step. ServiceTypeStep )
type Step ¶
Step provides an extended service.
func (Step) BuildCommand ¶
BuildCommand returns the command to build a new image for s.
func (Step) Check ¶ added in v0.4.0
Check validates Step s, returns nil if ok, otherwise returns found error.
func (Step) Dependencies ¶
Dependencies returns all steps needed for running s.
func (Step) IsBuildable ¶ added in v0.4.0
IsBuildable returns whether or not the step can be build.
func (Step) IsPullable ¶ added in v0.4.0
IsPullable returns whether or not a image is pulled for this step.
func (Step) PullCommand ¶
PullCommand returns the command to pull the image for step s.
func (Step) RunCommand ¶
RunCommand returns the command to run an instance of step s.