builddef

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: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HealthcheckTypeDisabled = HealthcheckType("disabled")
	HealthcheckTypeHTTP     = HealthcheckType("http")
	HealthcheckTypeFCGI     = HealthcheckType("fcgi")
	HealthcheckTypeCmd      = HealthcheckType("cmd")
)

Variables

View Source
var (
	ContextTypeGit   = ContextType("git")
	ContextTypeLocal = ContextType("local")
)
View Source
var (
	ZbuildLabel = "io.zbuild"
)

Functions

func DecodeBoolToHealthcheck

func DecodeBoolToHealthcheck(
	defaultHealthcheck HealthcheckConfig,
) mapstructure.DecodeHookFuncKind

func LockFilepath

func LockFilepath(ymlFile string) string

Types

type BuildDef

type BuildDef struct {
	// Kind property which represent the type of specialized build definition
	// the RawConfig property is holding.
	Kind string `yaml:"kind"`
	// RawConfig is the map of properties used by that specific Kind of
	// specialized build definition.
	RawConfig map[string]interface{} `yaml:",inline" hash:"set"`
	// RawLocks holds the map of locked properties used by that specific Kind
	// of specialized build definition.
	RawLocks RawLocks `yaml:"-" hash:"-"`
}

BuildDef is the generic data structure holding a generic build definition. It's composed of a kind, the only generic property, and of a RawConfig, which holds all the specialized properties (depending on the Kind). Also, it contains the RawLocks associated with the RawConfig.

func (BuildDef) Hash

func (def BuildDef) Hash() uint64

Hash returns a FNV hash of the BuildDef struct. This is used to ensure that the Locks aren't out-of-sync with the BuildDef.

type BuildOpts

type BuildOpts struct {
	Def         *BuildDef
	SourceState *llb.State
	SessionID   string
	// LocalUniqueID is useful mostly for test purpose, in order to use
	// a predefine value and have stable op digests.
	LocalUniqueID string
	// IgnoreLayerCache determines wheter layer caching shall be disabled. It's
	// the responsibility of specialized kind handlers to correctly apply this
	// option.
	IgnoreLayerCache bool
	// WithCacheMounts determines if the specialized builders should use a
	// custom cache to store downloaded pckages, compiled files, etc...
	WithCacheMounts  bool
	CacheIDNamespace string
	File             string
	LockFile         string
	Stage            string
	BuildContext     *Context
}

BuildOpts represents the parameters passed to specialized builders. (see github.com/NiR-/zbuild/pkg/defkinds/)

func NewBuildOpts

func NewBuildOpts(file, context, stage, sessionID, cacheIDNamespace string) (BuildOpts, error)

type Context

type Context struct {
	GitContext `mapstructure:",squash"`

	Type ContextType
	// Source is either the name of the local context or the URI of the remote
	// context.
	Source string `mapstructure:"source"`
}

func NewContext

func NewContext(source string, contextType string) (*Context, error)

NewContext takes a source which can be either a string starting with "git://" followed by a repo URI or a local context name. It also takes an optional contextType that can be used to force the type of the context (no inference on the source format will be done).

func (*Context) Copy

func (base *Context) Copy() *Context

func (*Context) IsGitContext

func (c *Context) IsGitContext() bool

func (*Context) IsLocalContext

func (c *Context) IsLocalContext() bool

func (*Context) IsValid

func (c *Context) IsValid() error

func (*Context) RawLocks

func (c *Context) RawLocks() map[string]interface{}

func (*Context) Subdir

func (c *Context) Subdir() string

Subdir returns the context Path if the context is Git-based. This method should be prefered over accessing Path directly since the Path can be set by users. It doesn't support local context because Buildkit clients' scope the build contexts to the build dir they're instructed to use. Thus, context dir for local contexts as no meaning.

type ContextType

type ContextType string

func (ContextType) IsValid

func (ctype ContextType) IsValid() error

type GitContext

type GitContext struct {
	Reference string
	// Path contains the base root dir of the context in the git repo.
	Path string
}

type HealthcheckCmd

type HealthcheckCmd struct {
	Shell   bool
	Command []string
}

HealthcheckCmd are healthcheck parameters that can be specified in specialized definition files when using cmd healthcheck type.

type HealthcheckConfig

type HealthcheckConfig struct {
	*HealthcheckHTTP `mapstructure:"http"`
	*HealthcheckFCGI `mapstructure:"fcgi"`
	*HealthcheckCmd  `mapstructure:"cmd"`

	Type     HealthcheckType
	Interval time.Duration
	Timeout  time.Duration
	Retries  int
}

HealthcheckConfig represents healthcheck as specified in specialized definition files.

func (*HealthcheckConfig) IsEnabled

func (hc *HealthcheckConfig) IsEnabled() bool

func (*HealthcheckConfig) IsValid

func (hc *HealthcheckConfig) IsValid(allowedTypes []string) bool

func (*HealthcheckConfig) ToImageConfig

func (hc *HealthcheckConfig) ToImageConfig() *image.HealthConfig

type HealthcheckFCGI

type HealthcheckFCGI struct {
	Path     string
	Expected string
}

HealthcheckFCGI are healthcheck parameters that can be specified in specialized definition files when using fcgi healthcheck type.

type HealthcheckHTTP

type HealthcheckHTTP struct {
	Path     string
	Expected string
}

HealthcheckHTTP are healthcheck parameters that can be specified in specialized definition files when using http healthcheck type.

type HealthcheckType

type HealthcheckType string

func (HealthcheckType) IsValid

func (hcType HealthcheckType) IsValid(allowed []string) bool

type Locks

type Locks interface {
	RawLocks() map[string]interface{}
}

Locks define a common interface implemented by all specialized Locks structs. Its unique method returns the locks as a map of interfaces, as used by mapstructure. This lets builder package arbitrarily manipulate the locks before writing them to disk. This is used to add the webserver locks when a webserver definition is embedded in a zbuildfile of another kind.

type OSRelease

type OSRelease struct {
	Name        string
	VersionName string
	VersionID   string
}

OSRelease represents the data about a Linux distribution as read from /etc/os-release. This struct is generally part of specialized definition locks and is used to determine which packages should be picked (e.g. php system packages inference).

func ParseOSRelease

func ParseOSRelease(file []byte) (OSRelease, error)

ParseOSRelease takes the raw content of a /etc/os-release file and transforms it into an OSRelease.

type PathsMap

type PathsMap map[string]string

PathsMap represents a set of paths with the source paths as keys and dest paths as values. It provides POSIX-like parameter expansion through its Interpolate() methods.

func (PathsMap) Copy

func (paths PathsMap) Copy() PathsMap

func (PathsMap) Interpolate

func (paths PathsMap) Interpolate(
	srcPrefix string,
	basedir string,
	params map[string]string,
) (map[string]string, error)

Interpolate expands POSIX-like parameters from the dest paths of the map using the given map of parameters and prepends all the source paths with the given prefix. Interpolated dest paths that aren't absolute are prefixed with the given basedir.

func (PathsMap) Merge

func (paths PathsMap) Merge(overriding PathsMap) PathsMap

func (PathsMap) SourcePaths

func (paths PathsMap) SourcePaths(srcPrefix string) []string

SourcePaths() returns the sorted list of sources paths from the map prepended with the given prefix.

type RawLocks

type RawLocks struct {
	// DefHash is the hash of the BuildDef the last time the locks were
	// generated. This is used to ensure that the lockfile is up-to-date with
	// the BuildDef. It's the only generic lock property, extracted from the
	// lockfile when loaded.
	DefHash uint64                 `yaml:"defhash"`
	Raw     map[string]interface{} `yaml:",inline"`
}

RawLocks holds the hash of the BuildDef these RawLocks are associated to, as well as a raw map of all the locked properties.

type UpdateLocksOpts

type UpdateLocksOpts struct {
	*BuildOpts

	// UpdateImageRef indicates whether the locked image reference shall be
	// updated.
	UpdateImageRef bool
	// UpdateSystemPackages indicates whether locked system packages shall be
	// updated.
	UpdateSystemPackages bool
	// UpdatePHPExtensions indicates whether PHP community extensions shall be
	// updated.
	UpdatePHPExtensions bool
}

UpdateLocksOpts represents the parameters passed to specialized builders to update a lockfile.

type VersionMap

type VersionMap map[string]string

VersionMap is a list of packages/extensions/etc... associated to version constraints or resolved versions. It has dedicated methods to manipulate items in the map, most notably Add() which can be used to add an item without overwriting any preexisting value. This is used in specialized defkind handlers to add infered items without rewriting manually-defined values.

func (*VersionMap) Add

func (set *VersionMap) Add(name, val string)

func (*VersionMap) Copy

func (set *VersionMap) Copy() *VersionMap

func (*VersionMap) Has

func (set *VersionMap) Has(name string) bool

func (*VersionMap) Len

func (set *VersionMap) Len() int

Len returns the number of versions in the map or 0 if the map is nil.

func (*VersionMap) Map

func (set *VersionMap) Map() map[string]string

func (*VersionMap) Merge

func (set *VersionMap) Merge(overriding *VersionMap)

func (*VersionMap) Names

func (set *VersionMap) Names() []string

func (*VersionMap) Overwrite

func (set *VersionMap) Overwrite(name, val string)

func (*VersionMap) Remove

func (set *VersionMap) Remove(name string)

Jump to

Keyboard shortcuts

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