registry

package
v0.0.0-...-25f2897 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrUnknownDefKind = xerrors.New("unknown kind")

ErrUnknownDefKind is returned when the decoded service has an unknown kind.

View Source
var Registry = NewKindRegistry()

Functions

func Register

func Register(name string, handler KindHandler, embedWebserverDef bool)

Types

type KindHandler

type KindHandler interface {
	// WithSolver sets the state solver that should be used when building or
	// update the locks. It serves as a generic way to read files or resolve
	// image references, whether the KindHandler is used inside a Buildkit
	// client or as a CLI tool.
	WithSolver(statesolver.StateSolver)
	// Build is the method called by the builder package when buildkit daemon
	// whenever a new build with zbuild syntax provider starts. It returns a LLB
	// DAG representing the build steps and the metadata of the final image, or
	// an error if something goes wrong during the build.
	Build(context.Context, builddef.BuildOpts) (llb.State, *image.Image, error)
	UpdateLocks(context.Context, pkgsolver.PackageSolversMap, builddef.UpdateLocksOpts) (builddef.Locks, error)
	// DebugConfig loads and parses its kind definition based on parameters in
	// the BuildOpts, like Build() method does. It returns the end struct used
	// to build a given stage, after all merge and inference operations
	// happened. This is used by zbuild CLI tool to show to its users the
	// complete config struct used to build a given stage.
	DebugConfig(builddef.BuildOpts) (interface{}, error)
}

KindHandler represents a series of methods used to build and update locks for a given kind of builddef.

func FindHandler

func FindHandler(defkind string) (KindHandler, error)

type KindRegistry

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

KindRegistry associates kinds with their respective handler.

func NewKindRegistry

func NewKindRegistry() *KindRegistry

NewKindRegistry creates an empty KindRegistry.

func (*KindRegistry) EmbedWebserverDef

func (reg *KindRegistry) EmbedWebserverDef(defkind string) bool

func (*KindRegistry) FindHandler

func (reg *KindRegistry) FindHandler(defkind string) (KindHandler, error)

FindHandler checks if there's a known handler for the given kind. It returns the builder if one is found and ErrUnknownDefKind otherwise.

func (*KindRegistry) Register

func (reg *KindRegistry) Register(
	name string,
	handler KindHandler,
	withWebserverDef bool,
)

Register adds a kind handler to the registry. The last parameter indicates whether this kind of definition embeds webserver definitions.

Jump to

Keyboard shortcuts

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