Documentation
¶
Overview ¶
Package project is a generated GoMock package.
Package project is a generated GoMock package.
Index ¶
- Constants
- Variables
- func Discover(root string) (*definitions.Project, []*definitions.Component, error)
- func GraphFromRules(rules []*Rule) *graph.Graph
- func HashFile(filePath string) (string, error)
- func LastModified(outputs []Resource) (time.Time, error)
- func MatchFiles(dir, pattern string) ([]string, error)
- func UUID() string
- func XDGCache() string
- type Chain
- type ClusterConfig
- type Code
- type Command
- type Component
- func (c *Component) App() string
- func (c *Component) Directory() string
- func (c *Component) Environment() map[string]string
- func (c *Component) Export(name string) (e *Export, found bool)
- func (c *Component) Exports() []*Export
- func (c *Component) HasRule(name string) bool
- func (c *Component) Kind() string
- func (c *Component) MustRule(name string) *Rule
- func (c *Component) Name() string
- func (c *Component) Project() *Project
- func (c *Component) Provider(name string) (Provider, error)
- func (c *Component) Rel(p string) (string, error)
- func (c *Component) RelPath() string
- func (c *Component) RelPaths(rs Resources) ([]string, error)
- func (c *Component) Rule(name string) (r *Rule, found bool)
- func (c *Component) Rules() []*Rule
- func (c *Component) Select(names []string) (result []*Rule)
- func (c *Component) Toolchain() (map[string]string, error)
- type Components
- func (comps Components) FilterKinds(kinds []string) []string
- func (comps Components) FilterNames(names []string) []string
- func (comps Components) FilterRules(rules []string) []string
- func (comps Components) First() *Component
- func (comps Components) Rule(name string) Rules
- func (comps Components) Rules(names []string) Rules
- func (comps Components) WithKind(kind ...string) Components
- func (comps Components) WithName(name ...string) Components
- func (comps Components) WithRule(rule ...string) Components
- type Dependency
- type Docker
- type DockerError
- type ExecOpts
- type Executor
- type Export
- type File
- type FileSystem
- type Image
- func (img *Image) AsFile() (string, error)
- func (img *Image) Cacheable() bool
- func (img *Image) Exists() (bool, error)
- func (img *Image) Hash() (string, error)
- func (img *Image) LastModified() (time.Time, error)
- func (img *Image) Name() string
- func (img *Image) OnFilesystem() bool
- func (img *Image) Path() string
- type Message
- type MockExecutor
- type MockExecutorMockRecorder
- type MockRunner
- type MockRunnerMockRecorder
- type Opts
- type Project
- func (p *Project) AbsPaths(paths []string) []string
- func (p *Project) ArtifactsDir() string
- func (p *Project) Components() Components
- func (p *Project) Export(component, exportName string) (*Export, bool)
- func (p *Project) Name() string
- func (p *Project) Provider(name string) (Provider, error)
- func (p *Project) Root() string
- func (p *Project) RootAbsPath() string
- func (p *Project) Rule(component, ruleName string) (*Rule, bool)
- func (p *Project) Select(names, kinds []string) (Components, error)
- func (p *Project) Toolchain(c *Component) (map[string]string, error)
- type Provider
- type Resource
- type Resources
- type Rule
- func (r *Rule) BaseEnvironment() map[string]string
- func (r *Rule) Commands() []*Command
- func (r *Rule) Component() *Component
- func (r *Rule) Dependencies() []*Rule
- func (r *Rule) DependencyOutputs() (outputs Resources)
- func (r *Rule) Environment() (map[string]string, error)
- func (r *Rule) HasOutputs() bool
- func (r *Rule) Image() string
- func (r *Rule) Inputs() (Resources, error)
- func (r *Rule) IsNative() bool
- func (r *Rule) MissingOutputs() (missing Resources)
- func (r *Rule) Name() string
- func (r *Rule) NodeID() string
- func (r *Rule) Outputs() (outputs Resources)
- func (r *Rule) OutputsExist() bool
- func (r *Rule) Project() *Project
- type Rules
- type RunOpts
- type Runner
- type RunnerBuilder
- type RunnerFunc
- type StandardRunner
- type Toolchain
- type ToolchainItem
Constants ¶
const ImageNotFound = DockerError("Image not found")
ImageNotFound indicates an image doesn't exist that matches a search
Variables ¶
var ( // Bright highlights text in the terminal Bright func(args ...interface{}) string // Cyan text color Cyan func(args ...interface{}) string // Green text color Green func(args ...interface{}) string // Red text color Red func(args ...interface{}) string // Yellow text color Yellow func(args ...interface{}) string )
Functions ¶
func Discover ¶
func Discover(root string) (*definitions.Project, []*definitions.Component, error)
Discover Components located within the given directory. The directory structure is searched recursively. Returns loaded Component definitions.
func GraphFromRules ¶
GraphFromRules builds a dependency graph originating from the specified Rules. The returned Graph contains the specified Rules plus all their direct and transitive dependencies.
func LastModified ¶
LastModified returns the most recent modification time for the given Resources
func MatchFiles ¶
MatchFiles returns files within the directory that match the pattern
Types ¶
type Chain ¶
type Chain struct {
// contains filtered or unexported fields
}
Chain of middleware
func NewChain ¶
func NewChain(constructors ...RunnerBuilder) Chain
NewChain creates a new Chain of middleware
func (Chain) Append ¶
func (c Chain) Append(constructors ...RunnerBuilder) Chain
Append extends a chain, adding the specified constructors as the last ones in the request flow. A new Chain is returned and the original is left untouched.
type ClusterConfig ¶
type ClusterConfig struct { Cluster string `json:"cluster"` TaskDefinitions map[string]string `json:"task_definitions"` SecurityGroup string `json:"security_group"` Subnets []string `json:"subnets"` Bucket string `json:"bucket"` Queue string `json:"queue"` Athens string `json:"athens"` }
ClusterConfig contains information needed to spawn tasks in ECS
func ReadClusterConfig ¶
func ReadClusterConfig(fpath string) (*ClusterConfig, error)
ReadClusterConfig reads a JSON configuration file from disk
type Code ¶
type Code int
Code indicates the scheduling result for a Rule
const ( // Error indicates the Rule could not be run Error Code = iota // UpToDate indicates the Rule is up-to-date and doesn't need to be run UpToDate // ExecError indicates Rule execution was attempted but failed ExecError // MissingOutputError indicates a Rule output was not produced MissingOutputError // OK indicates that the Rule executed successfully OK // Cached indicates the Rule artifact was cached Cached )
type Command ¶ added in v0.2.0
Command to be run by a Rule
func NewCommands ¶ added in v0.2.0
func NewCommands(self *definitions.Rule) (result []*Command, err error)
NewCommands constructs Commands extracted from a rule YAML definition
type Component ¶
type Component struct {
// contains filtered or unexported fields
}
Component to build and deploy in a repository
func NewComponent ¶
func NewComponent(p *Project, self *definitions.Component) (*Component, error)
NewComponent initializes a Component from its YAML definition.
func (*Component) App ¶
App is the application name relating to this Component. This field is not leveraged by Zim in any particular way, but may be used to correlate this Component with a deployed application for example.
func (*Component) Environment ¶
Environment returns environment variables applicable to this Component
func (*Component) Exports ¶
Exports returns a slice containing all Exports defined by this Component
func (*Component) RelPath ¶
RelPath returns the relative path to the Component within the repository
func (*Component) Rule ¶
Rule returns the Component rule with the given name, if it exists, along with a boolean that indicates whether it was found
type Components ¶
type Components []*Component
Components is a list of Components
func (Components) FilterKinds ¶ added in v0.2.0
func (comps Components) FilterKinds(kinds []string) []string
FilterKinds returns a slice of component kinds minus the given kinds
func (Components) FilterNames ¶ added in v0.2.0
func (comps Components) FilterNames(names []string) []string
FilterNames returns a slice of component names minus the given names
func (Components) FilterRules ¶ added in v0.2.0
func (comps Components) FilterRules(rules []string) []string
FilterRules returns a slice of component rules minus the given rules
func (Components) First ¶
func (comps Components) First() *Component
First component in the list, or nil if the list is empty
func (Components) Rule ¶
func (comps Components) Rule(name string) Rules
Rule returns a slice of all Rules with the given name across all these Components
func (Components) Rules ¶
func (comps Components) Rules(names []string) Rules
Rules returns a slice of all Rules with the given names across all these Components
func (Components) WithKind ¶
func (comps Components) WithKind(kind ...string) Components
WithKind filters the Components to those with matching kind
func (Components) WithName ¶
func (comps Components) WithName(name ...string) Components
WithName filters the Components to those with matching names
func (Components) WithRule ¶ added in v0.2.0
func (comps Components) WithRule(rule ...string) Components
WithRule filters the Components to those with matching rule names
type Dependency ¶
Dependency on another Component (a Rule or an Export)
type Docker ¶
type Docker struct {
// contains filtered or unexported fields
}
Docker is a type used to interact with the Docker daemon. It is used to work with Docker images as Zim Resources. This implements the Provider Go interface.
func (*Docker) FindImages ¶
FindImages finds an image with the given name. This may or may not include an image tag.
func (*Docker) Match ¶
Match existing Docker images according to the given pattern. Example patterns: "foo", "foo:latest", etc.
type DockerError ¶
type DockerError string
DockerError is a simple error type
func (DockerError) Error ¶
func (e DockerError) Error() string
type ExecOpts ¶
type ExecOpts struct { Name string Command string WorkingDirectory string Stdout io.Writer Stderr io.Writer Cmdout io.Writer Env []string Image string Debug bool }
ExecOpts are options used to run a command
type Executor ¶
type Executor interface { // Execute a command Execute(ctx context.Context, opts ExecOpts) error // UsesDocker indicates whether this executor runs commands in a container UsesDocker() bool }
Executor is an interface for executing commands
func NewBashExecutor ¶
func NewBashExecutor() Executor
NewBashExecutor returns an Executor that runs commands via bash
func NewDockerExecutor ¶
NewDockerExecutor returns an Executor that runs commands within containers
type File ¶
type File struct {
// contains filtered or unexported fields
}
File implements the Resource interface
func (*File) LastModified ¶
LastModified time of this File
type FileSystem ¶
type FileSystem struct {
// contains filtered or unexported fields
}
FileSystem implements Provider
func (*FileSystem) Init ¶
func (fs *FileSystem) Init(opts map[string]interface{}) error
Init accepts configuration options from Project configuration
func (*FileSystem) Match ¶
func (fs *FileSystem) Match(pattern string) (Resources, error)
Match files by name
func (*FileSystem) Name ¶
func (fs *FileSystem) Name() string
Name identifies the type of the FileSystem Provider
func (*FileSystem) New ¶
func (fs *FileSystem) New(path string) Resource
New returns a File Resource
type Image ¶
type Image struct {
// contains filtered or unexported fields
}
Image implements the Resource interface for Docker images
func (*Image) LastModified ¶
LastModified time of this Docker image. This corresponds to the image build time. It is not updated when a docker build detects that an image already exists.
type Message ¶
type Message struct { BuildID string `json:"build_id"` Bucket string `json:"bucket"` OutputKey string `json:"output_key"` ResultKey string `json:"result_key"` SourceKey string `json:"source_key"` CommitID string `json:"commit_id"` Component string `json:"component"` Rule string `json:"rule"` Time time.Time `json:"time"` Exit bool `json:"exit"` ResponseQueue string `json:"response_queue"` Output string `json:"output"` Error string `json:"error"` Worker string `json:"worker"` Kind string `json:"kind"` Text string `json:"text"` Success bool `json:"success"` }
Message sent to give updates on progress
type MockExecutor ¶
type MockExecutor struct {
// contains filtered or unexported fields
}
MockExecutor is a mock of Executor interface
func NewMockExecutor ¶
func NewMockExecutor(ctrl *gomock.Controller) *MockExecutor
NewMockExecutor creates a new mock instance
func (*MockExecutor) EXPECT ¶
func (m *MockExecutor) EXPECT() *MockExecutorMockRecorder
EXPECT returns an object that allows the caller to indicate expected use
func (*MockExecutor) Execute ¶
func (m *MockExecutor) Execute(ctx context.Context, opts ExecOpts) error
Execute mocks base method
func (*MockExecutor) UsesDocker ¶
func (m *MockExecutor) UsesDocker() bool
UsesDocker mocks base method
type MockExecutorMockRecorder ¶
type MockExecutorMockRecorder struct {
// contains filtered or unexported fields
}
MockExecutorMockRecorder is the mock recorder for MockExecutor
func (*MockExecutorMockRecorder) Execute ¶
func (mr *MockExecutorMockRecorder) Execute(ctx, opts interface{}) *gomock.Call
Execute indicates an expected call of Execute
func (*MockExecutorMockRecorder) UsesDocker ¶
func (mr *MockExecutorMockRecorder) UsesDocker() *gomock.Call
UsesDocker indicates an expected call of UsesDocker
type MockRunner ¶
type MockRunner struct {
// contains filtered or unexported fields
}
MockRunner is a mock of Runner interface
func NewMockRunner ¶
func NewMockRunner(ctrl *gomock.Controller) *MockRunner
NewMockRunner creates a new mock instance
func (*MockRunner) EXPECT ¶
func (m *MockRunner) EXPECT() *MockRunnerMockRecorder
EXPECT returns an object that allows the caller to indicate expected use
type MockRunnerMockRecorder ¶
type MockRunnerMockRecorder struct {
// contains filtered or unexported fields
}
MockRunnerMockRecorder is the mock recorder for MockRunner
func (*MockRunnerMockRecorder) Run ¶
func (mr *MockRunnerMockRecorder) Run(arg0, arg1, arg2 interface{}) *gomock.Call
Run indicates an expected call of Run
type Opts ¶
type Opts struct { Root string ProjectDef *definitions.Project ComponentDefs []*definitions.Component Providers []Provider Executor Executor }
Opts defines options used when initializing a Project
type Project ¶
Project is a collection of Components that can be built and deployed
func NewWithOptions ¶
NewWithOptions returns a project based on the given options
func (*Project) AbsPaths ¶
AbsPaths returns absolute file paths given paths relative to the project root
func (*Project) ArtifactsDir ¶
ArtifactsDir returns the absolute path to the directory used for artifacts
func (*Project) Components ¶
func (p *Project) Components() Components
Components returns all Components within the project
func (*Project) Export ¶
Export returns the specified Export and a boolean indicating whether it was found
func (*Project) Provider ¶
Provider returns the Provider with the given name, creating it if possible
func (*Project) RootAbsPath ¶
RootAbsPath returns the absolute path to the root of the project
func (*Project) Rule ¶
Rule returns the specified Rule and a boolean indicating whether it was found
func (*Project) Select ¶
func (p *Project) Select(names, kinds []string) (Components, error)
Select returns components with matching names or kind
func (*Project) Toolchain ¶
Toolchain returns information for the given component about the build tool versions used in the build. Components that use the same toolchain query will result in using the previously discovered values. This function accounts for whether the command executes within a Docker container.
type Provider ¶
type Provider interface { // Init gives options to the Provider Init(options map[string]interface{}) error // Name identifies the Provider type Name() string // New creates a Resource New(path string) Resource // Match Resources according to the given pattern Match(pattern string) (Resources, error) }
Provider describes an interface for managing Resources
type Resource ¶
type Resource interface { // Name of the Resource Name() string // Path to the output Path() string // Exists indicates whether the Resource is present Exists() (bool, error) // Hash of this Resource Hash() (string, error) // LastModified time of this Resource LastModified() (time.Time, error) // OnFilesystem returns true if it is backed by a file on disk OnFilesystem() bool // Cacheable indicates whether the resource can be stored in a cache Cacheable() bool // AsFile returns the path to a file containing the Resource itself, or // a representation of the Resource AsFile() (string, error) }
Resource is in an interface representing an artifact created by a rule
type Resources ¶
type Resources []Resource
Resources is shorthand for a slice of Resources
func (Resources) LastModified ¶
LastModified returns the most recent modification of all these Resources
type Rule ¶
type Rule struct {
// contains filtered or unexported fields
}
Rule is an operation on a Component
func (*Rule) BaseEnvironment ¶
BaseEnvironment returns Rule environment variables that are known upfront
func (*Rule) Dependencies ¶
Dependencies of this rule. In order for this to Rule to run, its Dependencies should first be run.
func (*Rule) DependencyOutputs ¶
DependencyOutputs returns outputs of this Rule's dependencies
func (*Rule) Environment ¶
Environment returns variables to be used when executing this Rule
func (*Rule) HasOutputs ¶
HasOutputs returns true if this Rule produces one or more output Resources
func (*Rule) IsNative ¶ added in v0.2.0
IsNative returns true if Docker execution is disabled on this rule
func (*Rule) MissingOutputs ¶
MissingOutputs returns a list of output files that are not currently present
func (*Rule) Outputs ¶
Outputs returns Resources that are created by the Rule. The result here is NOT dependent on whether or not the Resources currently exist.
func (*Rule) OutputsExist ¶
OutputsExist returns true if all rule output files are present on disk
type RunOpts ¶
type RunOpts struct { BuildID string Executor Executor Output io.Writer DebugOutput io.Writer Debug bool }
RunOpts contains options used to configure the running of Rules
type Runner ¶
Runner is an interface used to run Rules. Different implementations may decorate the standard behavior.
func BufferedOutput ¶
BufferedOutput is middleware that shows rule stdout and stderr
type RunnerBuilder ¶
RunnerBuilder for creating Runner middleware
type RunnerFunc ¶
The RunnerFunc type is an adapter to allow the use of ordinary functions as Runners. This mimics http.HandlerFunc from the standard library.
type StandardRunner ¶
type StandardRunner struct{}
StandardRunner defines good default behavior for running a Rule
type Toolchain ¶
type Toolchain struct {
Items []ToolchainItem
}
Toolchain identifies dependencies this component has on build tools. This may be used to identify changes in toolchain that may necessitate a rebuild.
type ToolchainItem ¶
ToolchainItem is one part of a Component Toolchain