Documentation ¶
Overview ¶
Copyright 2020 Fugue, Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2020 Fugue, Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2020 Fugue, Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2020 Fugue, Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2020 Fugue, Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2020 Fugue, Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2020 Fugue, Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2020 Fugue, Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2020 Fugue, Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2020 Fugue, Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2020 Fugue, Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2020 Fugue, Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2020 Fugue, Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2020 Fugue, Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2020 Fugue, Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Package project is a generated GoMock package.
Copyright 2020 Fugue, Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2020 Fugue, Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- Variables
- func CheckCondition(ctx context.Context, r *Rule, c Condition, opts RunOpts, ...) (bool, error)
- func CheckConditions(ctx context.Context, r *Rule, opts RunOpts, executor exec.Executor, ...) (bool, error)
- 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
- type Chain
- 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 Condition
- type ConditionScript
- type Dependency
- type Export
- type File
- type FileSystem
- 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) ArtifactsDir() string
- 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 ¶
This section is empty.
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 CheckCondition ¶ added in v0.3.0
func CheckCondition( ctx context.Context, r *Rule, c Condition, opts RunOpts, executor exec.Executor, env map[string]string, ) (bool, error)
CheckCondition returns true if the given Rule condition is met. The provided executor is used to run any scripting required to check the conditions.
func CheckConditions ¶ added in v0.3.0
func CheckConditions( ctx context.Context, r *Rule, opts RunOpts, executor exec.Executor, env map[string]string, ) (bool, error)
CheckConditions returns true if the Rule should execute based on all of its conditions being met. The provided executor is used to run any scripting required to check the conditions.
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 Code ¶
type Code int
Code indicates the scheduling result for a Rule
const ( // Error indicates the Rule could not be run Error Code = iota // Skipped indicates the Rule was skipped due to a conditional Skipped // 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 Condition ¶ added in v0.3.0
type Condition struct { ResourceExists string DirectoryExists string ScriptSucceeds ConditionScript }
Condition controlling whether a Rule executes
type ConditionScript ¶ added in v0.3.0
ConditionScript defines a shell script to run for a Condition check
func (ConditionScript) IsEmpty ¶ added in v0.3.0
func (s ConditionScript) IsEmpty() bool
IsEmpty returns true if the Script is not defined
type Dependency ¶
Dependency on another Component (a Rule or an Export)
type Export ¶
type Export struct { Component *Component Provider Provider Resources []string Ignore []string // contains filtered or unexported fields }
Export defines resources exposed by a Component. The resources referenced by an export must be static, which allows the export to be resolved only once.
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 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 exec.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) ArtifactsDir ¶ added in v0.3.0
ArtifactsDir returns the absolute path to the directory used for artifacts produced by this Rule.
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 exec.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