Documentation
¶
Index ¶
- Variables
- func ApplyFilter(filter Filter, release string, architecture string, variant string, ...) bool
- func Copy(src, dest string) error
- func CreateGPGKeyring(keyserver string, keys []string) (string, error)
- func DownloadHash(def DefinitionImage, file, checksum string, hashFunc hash.Hash) (string, error)
- func GetArch(distro, arch string) (string, error)
- func GetExpiryDate(creationDate time.Time, format string) time.Time
- func GetSignedContent(signedFile string, keys []string, keyserver string) ([]byte, error)
- func GetTargetDir(def DefinitionImage) string
- func Pack(filename, compression, path string, args ...string) error
- func PackUpdate(filename, compression, path string, args ...string) error
- func RenderTemplate(template string, iface interface{}) (string, error)
- func RunCommand(name string, arg ...string) error
- func RunScript(content string) error
- func SetupChroot(rootfs string, envs DefinitionEnv, m []ChrootMount) (func() error, error)
- func VerifyFile(signedFile, signatureFile string, keys []string, keyserver string) (bool, error)
- type ChrootMount
- type CustomManagerCmd
- type Definition
- type DefinitionAction
- type DefinitionEnv
- type DefinitionEnvVars
- type DefinitionFile
- type DefinitionFileTemplate
- type DefinitionFilter
- type DefinitionImage
- type DefinitionMappings
- type DefinitionPackages
- type DefinitionPackagesCustomManager
- type DefinitionPackagesRepository
- type DefinitionPackagesSet
- type DefinitionSource
- type DefinitionTarget
- type DefinitionTargetLXC
- type DefinitionTargetLXCConfig
- type DefinitionTargetLXD
- type DefinitionTargetLXDVM
- type EnvVariable
- type Environment
- type Filter
- type ImageTarget
Constants ¶
This section is empty.
Variables ¶
var ActiveChroots = make(map[string]func() error)
ActiveChroots is a map of all active chroots and their exit functions
Functions ¶
func ApplyFilter ¶
func ApplyFilter(filter Filter, release string, architecture string, variant string, targetType string, acceptedImageTargets ImageTarget) bool
ApplyFilter returns true if the filter matches.
func CreateGPGKeyring ¶
CreateGPGKeyring creates a new GPG keyring.
func DownloadHash ¶
DownloadHash downloads a file. If a checksum file is provided, it will try and match the hash.
func GetExpiryDate ¶
GetExpiryDate returns an expiry date based on the creationDate and format.
func GetSignedContent ¶
GetSignedContent verifies the provided file, and returns its decrypted (plain) content.
func GetTargetDir ¶
func GetTargetDir(def DefinitionImage) string
GetTargetDir returns the path to which source files are downloaded.
func PackUpdate ¶
PackUpdate updates an existing tarball.
func RenderTemplate ¶
RenderTemplate renders a pongo2 template.
func RunCommand ¶
RunCommand runs a command hereby setting the SHELL and PATH env variables, and redirecting the process's stdout and stderr to the real stdout and stderr respectively.
func RunScript ¶
RunScript runs a script hereby setting the SHELL and PATH env variables, and redirecting the process's stdout and stderr to the real stdout and stderr respectively.
func SetupChroot ¶
func SetupChroot(rootfs string, envs DefinitionEnv, m []ChrootMount) (func() error, error)
SetupChroot sets up mount and files, a reverter and then chroots for you
Types ¶
type ChrootMount ¶
type ChrootMount struct {
Source string
Target string
FSType string
Flags uintptr
Data string
IsDir bool
}
ChrootMount defines mount args.
type CustomManagerCmd ¶
type CustomManagerCmd struct {
Command string `yaml:"cmd"`
Flags []string `yaml:"flags,omitempty"`
}
CustomManagerCmd represents a command for a custom manager.
type Definition ¶
type Definition struct {
Image DefinitionImage `yaml:"image"`
Source DefinitionSource `yaml:"source"`
Targets DefinitionTarget `yaml:"targets,omitempty"`
Files []DefinitionFile `yaml:"files,omitempty"`
Packages DefinitionPackages `yaml:"packages,omitempty"`
Actions []DefinitionAction `yaml:"actions,omitempty"`
Mappings DefinitionMappings `yaml:"mappings,omitempty"`
Environment DefinitionEnv `yaml:"environment,omitempty"`
}
A Definition a definition.
func (*Definition) GetEarlyPackages ¶
func (d *Definition) GetEarlyPackages(action string) []string
GetEarlyPackages returns a list of packages which are to be installed or removed earlier than the actual package handling Also removes them from the package set so they aren't attempted to be re-installed again as normal packages
func (*Definition) GetRunnableActions ¶
func (d *Definition) GetRunnableActions(trigger string, imageTarget ImageTarget) []DefinitionAction
GetRunnableActions returns a list of actions depending on the trigger and releases.
func (*Definition) SetDefaults ¶
func (d *Definition) SetDefaults()
SetDefaults sets some default values.
func (*Definition) SetValue ¶
func (d *Definition) SetValue(key string, value string) error
SetValue writes the provided value to a field represented by the yaml tag 'key'.
func (*Definition) Validate ¶
func (d *Definition) Validate() error
Validate validates the Definition.
type DefinitionAction ¶
type DefinitionAction struct {
DefinitionFilter `yaml:",inline"`
Trigger string `yaml:"trigger"`
Action string `yaml:"action"`
}
A DefinitionAction specifies a custom action (script) which is to be run after a certain action.
type DefinitionEnv ¶
type DefinitionEnv struct {
ClearDefaults bool `yaml:"clear_defaults,omitempty"`
EnvVariables []DefinitionEnvVars `yaml:"variables,omitempty"`
}
DefinitionEnv represents the config part of the environment section.
type DefinitionEnvVars ¶
DefinitionEnvVars defines custom environment variables.
type DefinitionFile ¶
type DefinitionFile struct {
DefinitionFilter `yaml:",inline"`
Generator string `yaml:"generator"`
Path string `yaml:"path,omitempty"`
Content string `yaml:"content,omitempty"`
Name string `yaml:"name,omitempty"`
Template DefinitionFileTemplate `yaml:"template,omitempty"`
Templated bool `yaml:"templated,omitempty"`
Mode string `yaml:"mode,omitempty"`
GID string `yaml:"gid,omitempty"`
UID string `yaml:"uid,omitempty"`
Pongo bool `yaml:"pongo,omitempty"`
Source string `yaml:"source,omitempty"`
}
A DefinitionFile represents a file which is to be created inside to chroot.
type DefinitionFileTemplate ¶
type DefinitionFileTemplate struct {
Properties map[string]string `yaml:"properties,omitempty"`
When []string `yaml:"when,omitempty"`
}
A DefinitionFileTemplate represents the settings used by generators
type DefinitionFilter ¶
type DefinitionFilter struct {
Releases []string `yaml:"releases,omitempty"`
Architectures []string `yaml:"architectures,omitempty"`
Variants []string `yaml:"variants,omitempty"`
Types []string `yaml:"types,omitempty"`
}
A DefinitionFilter defines filters for various actions.
func (*DefinitionFilter) GetArchitectures ¶
func (d *DefinitionFilter) GetArchitectures() []string
GetArchitectures returns a list of architectures.
func (*DefinitionFilter) GetReleases ¶
func (d *DefinitionFilter) GetReleases() []string
GetReleases returns a list of releases.
func (*DefinitionFilter) GetTypes ¶
func (d *DefinitionFilter) GetTypes() []string
GetTypes returns a list of types.
func (*DefinitionFilter) GetVariants ¶
func (d *DefinitionFilter) GetVariants() []string
GetVariants returns a list of variants.
type DefinitionImage ¶
type DefinitionImage struct {
Description string `yaml:"description"`
Distribution string `yaml:"distribution"`
Release string `yaml:"release,omitempty"`
Architecture string `yaml:"architecture,omitempty"`
Expiry string `yaml:"expiry,omitempty"`
Variant string `yaml:"variant,omitempty"`
Name string `yaml:"name,omitempty"`
Serial string `yaml:"serial,omitempty"`
// Internal fields (YAML input ignored)
ArchitectureMapped string `yaml:"architecture_mapped,omitempty"`
ArchitectureKernel string `yaml:"architecture_kernel,omitempty"`
ArchitecturePersonality string `yaml:"architecture_personality,omitempty"`
}
A DefinitionImage represents the image.
type DefinitionMappings ¶
type DefinitionMappings struct {
Architectures map[string]string `yaml:"architectures,omitempty"`
ArchitectureMap string `yaml:"architecture_map,omitempty"`
}
DefinitionMappings defines custom mappings.
type DefinitionPackages ¶
type DefinitionPackages struct {
Manager string `yaml:"manager,omitempty"`
CustomManager *DefinitionPackagesCustomManager `yaml:"custom-manager,omitempty"`
Update bool `yaml:"update,omitempty"`
Cleanup bool `yaml:"cleanup,omitempty"`
Sets []DefinitionPackagesSet `yaml:"sets,omitempty"`
Repositories []DefinitionPackagesRepository `yaml:"repositories,omitempty"`
}
A DefinitionPackages represents a package handler.
type DefinitionPackagesCustomManager ¶
type DefinitionPackagesCustomManager struct {
Clean CustomManagerCmd `yaml:"clean"`
Install CustomManagerCmd `yaml:"install"`
Remove CustomManagerCmd `yaml:"remove"`
Refresh CustomManagerCmd `yaml:"refresh"`
Update CustomManagerCmd `yaml:"update"`
Flags []string `yaml:"flags,omitempty"`
}
DefinitionPackagesCustomManager represents a custom package manager.
type DefinitionPackagesRepository ¶
type DefinitionPackagesRepository struct {
DefinitionFilter `yaml:",inline"`
Name string `yaml:"name"` // Name of the repository
URL string `yaml:"url"` // URL (may differ based on manager)
Type string `yaml:"type,omitempty"` // For distros that have more than one repository manager
Key string `yaml:"key,omitempty"` // GPG armored keyring
}
A DefinitionPackagesRepository contains data of a specific repository
type DefinitionPackagesSet ¶
type DefinitionPackagesSet struct {
DefinitionFilter `yaml:",inline"`
Packages []string `yaml:"packages"`
Action string `yaml:"action"`
Early bool `yaml:"early,omitempty"`
Flags []string `yaml:"flags,omitempty"`
}
A DefinitionPackagesSet is a set of packages which are to be installed or removed.
type DefinitionSource ¶
type DefinitionSource struct {
Downloader string `yaml:"downloader"`
URL string `yaml:"url,omitempty"`
Keys []string `yaml:"keys,omitempty"`
Keyserver string `yaml:"keyserver,omitempty"`
Variant string `yaml:"variant,omitempty"`
Suite string `yaml:"suite,omitempty"`
SameAs string `yaml:"same_as,omitempty"`
SkipVerification bool `yaml:"skip_verification,omitempty"`
}
A DefinitionSource specifies the download type and location
type DefinitionTarget ¶
type DefinitionTarget struct {
LXC DefinitionTargetLXC `yaml:"lxc,omitempty"`
LXD DefinitionTargetLXD `yaml:"lxd,omitempty"`
Type string // This field is internal only and used only for simplicity.
}
A DefinitionTarget specifies target dependent files.
type DefinitionTargetLXC ¶
type DefinitionTargetLXC struct {
CreateMessage string `yaml:"create-message,omitempty"`
Config []DefinitionTargetLXCConfig `yaml:"config,omitempty"`
}
A DefinitionTargetLXC represents LXC specific files as part of the metadata.
type DefinitionTargetLXCConfig ¶
type DefinitionTargetLXCConfig struct {
Type string `yaml:"type"`
Before uint `yaml:"before,omitempty"`
After uint `yaml:"after,omitempty"`
Content string `yaml:"content"`
}
A DefinitionTargetLXCConfig represents the config part of the metadata.
type DefinitionTargetLXD ¶
type DefinitionTargetLXD struct {
VM DefinitionTargetLXDVM `yaml:"vm,omitempty"`
}
DefinitionTargetLXD represents LXD specific options.
type DefinitionTargetLXDVM ¶
type DefinitionTargetLXDVM struct {
Size uint64 `yaml:"size,omitempty"`
Filesystem string `yaml:"filesystem,omitempty"`
}
DefinitionTargetLXDVM represents LXD VM specific options.
type EnvVariable ¶
EnvVariable represents a environment variable.
type Environment ¶
type Environment map[string]EnvVariable
Environment represents a set of environment variables.
func SetEnvVariables ¶
func SetEnvVariables(env Environment) Environment
SetEnvVariables sets the provided environment variables and returns the old ones.
type Filter ¶
type Filter interface {
GetReleases() []string
GetArchitectures() []string
GetVariants() []string
GetTypes() []string
}
Filter represents a filter.
type ImageTarget ¶
type ImageTarget int
ImageTarget represents the image target.
const ( // ImageTargetAll is used for all targets. ImageTargetAll ImageTarget = 1 // ImageTargetContainer is used for container targets. ImageTargetContainer ImageTarget = 1 << 1 // ImageTargetVM is used for VM targets. ImageTargetVM ImageTarget = 1 << 2 // ImageTargetUndefined is used when no type has been specified. ImageTargetUndefined ImageTarget = 1 << 3 )