project

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2022 License: Apache-2.0 Imports: 24 Imported by: 0

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

Constants

This section is empty.

Variables

View Source
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

func GraphFromRules(rules []*Rule) *graph.Graph

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 HashFile

func HashFile(filePath string) (string, error)

HashFile returns the SHA1 hash of File contents

func LastModified

func LastModified(outputs []Resource) (time.Time, error)

LastModified returns the most recent modification time for the given Resources

func MatchFiles

func MatchFiles(dir, pattern string) ([]string, error)

MatchFiles returns files within the directory that match the pattern

func UUID

func UUID() string

UUID returns a unique ID as a string

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.

func (Chain) Then

func (c Chain) Then(r Runner) Runner

Then chains the middleware and returns the final Runner.

NewChain(m1, m2, m3).Then(r)

is equivalent to:

m1(m2(m3(r)))

When the run call comes in, it will be passed to m1, then m2, then m3 and finally, the given handler (assuming every middleware calls the following one).

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

type Command struct {
	Kind       string
	Argument   string
	Attributes map[string]interface{}
}

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

func (c *Component) App() string

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) Directory

func (c *Component) Directory() string

Directory returns the absolute path to the Component directory

func (*Component) Environment

func (c *Component) Environment() map[string]string

Environment returns environment variables applicable to this Component

func (*Component) Export

func (c *Component) Export(name string) (e *Export, found bool)

Export returns the Component export with the given name, if it exists

func (*Component) Exports

func (c *Component) Exports() []*Export

Exports returns a slice containing all Exports defined by this Component

func (*Component) HasRule

func (c *Component) HasRule(name string) bool

HasRule returns true if a Rule with the given name is defined

func (*Component) Kind

func (c *Component) Kind() string

Kind of the Component which determines its base settings

func (*Component) MustRule

func (c *Component) MustRule(name string) *Rule

MustRule returns the named rule or panics if it is not found

func (*Component) Name

func (c *Component) Name() string

Name of the Component which must be unique within the repository

func (*Component) Project

func (c *Component) Project() *Project

Project returns the Project that contains this Component

func (*Component) Provider

func (c *Component) Provider(name string) (Provider, error)

Provider returns the Provider with the given name

func (*Component) Rel

func (c *Component) Rel(p string) (string, error)

Rel returns the relative path from the Component to the given path

func (*Component) RelPath

func (c *Component) RelPath() string

RelPath returns the relative path to the Component within the repository

func (*Component) RelPaths

func (c *Component) RelPaths(rs Resources) ([]string, error)

RelPaths returns relative paths from the Component to the given paths

func (*Component) Rule

func (c *Component) Rule(name string) (r *Rule, found bool)

Rule returns the Component rule with the given name, if it exists, along with a boolean that indicates whether it was found

func (*Component) Rules

func (c *Component) Rules() []*Rule

Rules returns a slice containing all Rules defined by this Component

func (*Component) Select

func (c *Component) Select(names []string) (result []*Rule)

Select finds Rules belonging to this Component with the provided names. Unknown names are just ignored.

func (*Component) Toolchain

func (c *Component) Toolchain() (map[string]string, error)

Toolchain returns this Components active toolchain information

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

func (Condition) IsEmpty added in v0.3.0

func (c Condition) IsEmpty() bool

IsEmpty returns true if the condition isn't configured

type ConditionScript added in v0.3.0

type ConditionScript struct {
	Run           string
	WithOutput    string
	SuppressError bool
}

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

type Dependency struct {
	Component string
	Rule      string
	Export    string
	Recurse   int
}

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.

func (*Export) Resolve added in v0.3.0

func (e *Export) Resolve() (Resources, error)

Resolve the specific resources that this export exposes. This often takes a glob-like pattern and finds the corresponding specific list of files. This will be called from multiple goroutines.

type File

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

File implements the Resource interface

func NewFile

func NewFile(path string) *File

NewFile returns a File given the path

func (*File) AsFile

func (f *File) AsFile() (string, error)

AsFile returns the path to the file

func (*File) Cacheable

func (f *File) Cacheable() bool

Cacheable is true for Files since they can be uploaded to a cache

func (*File) Exists

func (f *File) Exists() (bool, error)

Exists indicates whether the File currently exists

func (*File) Hash

func (f *File) Hash() (string, error)

Hash of File contents

func (*File) LastModified

func (f *File) LastModified() (time.Time, error)

LastModified time of this File

func (*File) Name

func (f *File) Name() string

Name of the Resource

func (*File) OnFilesystem

func (f *File) OnFilesystem() bool

OnFilesystem is true for files

func (*File) Path

func (f *File) Path() string

Path returns the absolute path to the File

type FileSystem

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

FileSystem implements Provider

func NewFileSystem

func NewFileSystem(root string) (*FileSystem, error)

NewFileSystem returns

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

func (*MockRunner) Run

func (m *MockRunner) Run(arg0 context.Context, arg1 *Rule, arg2 RunOpts) (Code, error)

Run mocks base method

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

type Project struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Project is a collection of Components that can be built and deployed

func New

func New(root string) (*Project, error)

New returns a Project that resides at the given root directory

func NewWithOptions

func NewWithOptions(opts Opts) (*Project, error)

NewWithOptions returns a project based on the given options

func (*Project) AbsPaths

func (p *Project) AbsPaths(paths []string) []string

AbsPaths returns absolute file paths given paths relative to the project root

func (*Project) ArtifactsDir

func (p *Project) ArtifactsDir() string

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

func (p *Project) Export(component, exportName string) (*Export, bool)

Export returns the specified Export and a boolean indicating whether it was found

func (*Project) Name

func (p *Project) Name() string

Name of the project

func (*Project) Provider

func (p *Project) Provider(name string) (Provider, error)

Provider returns the Provider with the given name, creating it if possible

func (*Project) Root

func (p *Project) Root() string

Root directory of the project

func (*Project) RootAbsPath

func (p *Project) RootAbsPath() string

RootAbsPath returns the absolute path to the root of the project

func (*Project) Rule

func (p *Project) Rule(component, ruleName string) (*Rule, bool)

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

func (p *Project) Toolchain(c *Component) (map[string]string, error)

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

func (rs Resources) LastModified() (t time.Time, err error)

LastModified returns the most recent modification of all these Resources

func (Resources) Paths

func (rs Resources) Paths() (paths []string)

Paths of all the Resources

func (Resources) RelativePaths

func (rs Resources) RelativePaths(base string) (paths []string, err error)

RelativePaths returns paths to these Resources relative to the given directory

type Rule

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

Rule is an operation on a Component

func NewRule

func NewRule(name string, c *Component, self *definitions.Rule) (*Rule, error)

NewRule constructs a Rule from a provided YAML definition

func (*Rule) ArtifactsDir added in v0.3.0

func (r *Rule) ArtifactsDir() string

ArtifactsDir returns the absolute path to the directory used for artifacts produced by this Rule.

func (*Rule) BaseEnvironment

func (r *Rule) BaseEnvironment() map[string]string

BaseEnvironment returns Rule environment variables that are known upfront

func (*Rule) Commands

func (r *Rule) Commands() []*Command

Commands that define Rule execution

func (*Rule) Component

func (r *Rule) Component() *Component

Component containing this Rule

func (*Rule) Dependencies

func (r *Rule) Dependencies() []*Rule

Dependencies of this rule. In order for this to Rule to run, its Dependencies should first be run.

func (*Rule) DependencyOutputs

func (r *Rule) DependencyOutputs() (outputs Resources)

DependencyOutputs returns outputs of this Rule's dependencies

func (*Rule) Environment

func (r *Rule) Environment() (map[string]string, error)

Environment returns variables to be used when executing this Rule

func (*Rule) HasOutputs

func (r *Rule) HasOutputs() bool

HasOutputs returns true if this Rule produces one or more output Resources

func (*Rule) Image

func (r *Rule) Image() string

Image returns the Docker image used to build this Rule, if configured

func (*Rule) Inputs

func (r *Rule) Inputs() (Resources, error)

Inputs returns Resources that are used to build this Rule

func (*Rule) IsNative added in v0.2.0

func (r *Rule) IsNative() bool

IsNative returns true if Docker execution is disabled on this rule

func (*Rule) MissingOutputs

func (r *Rule) MissingOutputs() (missing Resources)

MissingOutputs returns a list of output files that are not currently present

func (*Rule) Name

func (r *Rule) Name() string

Name returns the rule name e.g. "build"

func (*Rule) NodeID

func (r *Rule) NodeID() string

NodeID makes Rules adhere to the graph.Node interface

func (*Rule) Outputs

func (r *Rule) Outputs() (outputs Resources)

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

func (r *Rule) OutputsExist() bool

OutputsExist returns true if all rule output files are present on disk

func (*Rule) Project

func (r *Rule) Project() *Project

Project containing this Rule

type Rules

type Rules []*Rule

Rules is a list of Rules

func (Rules) First

func (rules Rules) First() *Rule

First rule in the list, or nil if the list is empty

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

type Runner interface {

	// Run a Rule
	Run(context.Context, *Rule, RunOpts) (Code, error)
}

Runner is an interface used to run Rules. Different implementations may decorate the standard behavior.

func BufferedOutput

func BufferedOutput(runner Runner) Runner

BufferedOutput is middleware that shows rule stdout and stderr

func Debug

func Debug(runner Runner) Runner

Debug is middleware that sets the debug flag to true

func Logger

func Logger(runner Runner) Runner

Logger is middleware that wraps logging around Rule execution

type RunnerBuilder

type RunnerBuilder func(Runner) Runner

RunnerBuilder for creating Runner middleware

type RunnerFunc

type RunnerFunc func(context.Context, *Rule, RunOpts) (Code, error)

The RunnerFunc type is an adapter to allow the use of ordinary functions as Runners. This mimics http.HandlerFunc from the standard library.

func (RunnerFunc) Run

func (f RunnerFunc) Run(ctx context.Context, r *Rule, opts RunOpts) (Code, error)

Run calls f(w, r).

type StandardRunner

type StandardRunner struct{}

StandardRunner defines good default behavior for running a Rule

func (*StandardRunner) Run

func (runner *StandardRunner) Run(ctx context.Context, r *Rule, opts RunOpts) (Code, error)

Run a rule with the provided executor and other options

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

type ToolchainItem struct {
	Name    string
	Command string
}

ToolchainItem is one part of a Component Toolchain

Jump to

Keyboard shortcuts

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