builder

package
v0.0.0-...-6d800d2 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2016 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const ContainerID = "containerID"

ContainerID is the key used to store the current ContainerID in the builder attributes.

Variables

This section is empty.

Functions

This section is empty.

Types

type CommitStep

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

CommitStep is a step that execute the delegated step and the commit the current container into a new image.

func (*CommitStep) Execute

func (s *CommitStep) Execute(ctx context.Context, helper libmason.Helper, config *Config) (*Config, error)

Execute implements Step.Execute. It executes the step based on the specified config and helper.

func (*CommitStep) String

func (s *CommitStep) String() string

type Config

type Config struct {
	ImageID    string
	Entrypoint strslice.StrSlice
	Cmd        strslice.StrSlice
	// contains filtered or unexported fields
}

Config holds builder configuration (like the ImageID and additionnal attributes).

func (*Config) Get

func (c *Config) Get(key string) (interface{}, bool)

Get returns the current attribute value and its existence from the specified key.

func (*Config) Put

func (c *Config) Put(key string, value interface{})

Put adds a new attributes defined by a key and value.

type CreateStep

type CreateStep struct {
	Cmd        []string
	Entrypoint []string
	Stdin      bool
	// contains filtered or unexported fields
}

CreateStep is a step that will create a container (based on the specified attributes) and and execute the specified delegate step in this container.

func (*CreateStep) Execute

func (s *CreateStep) Execute(ctx context.Context, helper libmason.Helper, config *Config) (*Config, error)

Execute implements Step.Execute. It executes the step based on the specified config and helper.

func (*CreateStep) String

func (s *CreateStep) String() string

type FromStep

type FromStep struct {
	Reference string
}

FromStep is the top-level step that should be. It's only valid if there is no other step executed before. It will get the specified image and put it into the builder config.

func (*FromStep) Execute

func (s *FromStep) Execute(ctx context.Context, helper libmason.Helper, config *Config) (*Config, error)

Execute implements Step.Execute. It executes the step based on the specified config and helper.

func (*FromStep) String

func (s *FromStep) String() string

type NoopStep

type NoopStep struct{}

NoopStep is a no-operation step, that does nothing

func (*NoopStep) Execute

func (s *NoopStep) Execute(ctx context.Context, helper libmason.Helper, config *Config) (*Config, error)

Execute implements Step.Execute. It executes the step based on the specified config and helper.

type RemoveStep

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

RemoveStep is a step that execute the delegated step and remove the current container

func (*RemoveStep) Execute

func (s *RemoveStep) Execute(ctx context.Context, helper libmason.Helper, config *Config) (*Config, error)

Execute implements Step.Execute. It executes the step based on the specified config and helper.

func (*RemoveStep) String

func (s *RemoveStep) String() string

type Step

type Step interface {
	// Execute the current step "content" using the specified helper and config.
	// The step should return the/an updated config (can be untouched too).
	Execute(ctx context.Context, helper libmason.Helper, config *Config) (*Config, error)
}

Step defines the method a builder step should define

func WithCommit

func WithCommit(step Step) Step

WithCommit creates a Commit Step with the specified step.

func WithCreate

func WithCreate(step Step, entrypoint, cmd []string, stdin bool) Step

WithCreate creates a Create step with the specified step (and argumeents)

func WithRemove

func WithRemove(step Step) Step

WithRemove creates a Remove Step with the specfied step.

type StepBuilder

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

StepBuilder is a builder that is composed of steps that are executed sequentially.

func NewBuilder

func NewBuilder(helper libmason.Helper) *StepBuilder

NewBuilder Creates a new step builder

func WithLogFunc

func WithLogFunc(builder *StepBuilder, fn func(string, ...interface{})) *StepBuilder

WithLogFunc sets the logging function to a builder and returns it. By default a builder has a noLog logging function (does nothing).

func WithSteps

func WithSteps(builder *StepBuilder, steps []Step) *StepBuilder

WithSteps sets the steps to execute to a builder and returns it.

func (*StepBuilder) Run

func (b *StepBuilder) Run(ctx context.Context) (string, error)

Run run the steps in order and returns the image ID generated. If a step fails, the run fails as well (at the first failure).

Jump to

Keyboard shortcuts

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