config

package
v0.6.11 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: Apache-2.0 Imports: 20 Imported by: 11

Documentation

Index

Constants

View Source
const (
	SubstitutionPackageName           = "${{package.name}}"
	SubstitutionPackageVersion        = "${{package.version}}"
	SubstitutionPackageFullVersion    = "${{package.full-version}}"
	SubstitutionPackageEpoch          = "${{package.epoch}}"
	SubstitutionPackageDescription    = "${{package.description}}"
	SubstitutionTargetsDestdir        = "${{targets.destdir}}"
	SubstitutionTargetsContextdir     = "${{targets.contextdir}}"
	SubstitutionSubPkgDir             = "${{targets.subpkgdir}}"
	SubstitutionHostTripletGnu        = "${{host.triplet.gnu}}"
	SubstitutionHostTripletRust       = "${{host.triplet.rust}}"
	SubstitutionCrossTripletGnuGlibc  = "${{cross.triplet.gnu.glibc}}"
	SubstitutionCrossTripletGnuMusl   = "${{cross.triplet.gnu.musl}}"
	SubstitutionCrossTripletRustGlibc = "${{cross.triplet.rust.glibc}}"
	SubstitutionCrossTripletRustMusl  = "${{cross.triplet.rust.musl}}"
	SubstitutionBuildArch             = "${{build.arch}}"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BuildOption

type BuildOption struct {
	Vars        map[string]string `yaml:"vars,omitempty"`
	Environment EnvironmentOption `yaml:"environment,omitempty"`
}

BuildOption describes an optional deviation to a package build.

type Checks

type Checks struct {
	// Optional: enable these linters that are not enabled by default.
	Enabled []string `json:"enabled,omitempty" yaml:"enabled,omitempty"`
	// Optional: disable these linters that are not enabled by default.
	Disabled []string `json:"disabled,omitempty" yaml:"disabled,omitempty"`
}

func (*Checks) GetLinters

func (chk *Checks) GetLinters() []string

Computes the list of package or subpackage linters, taking into account default linters. This includes the default linters as well, unless disabled.

type Configuration

type Configuration struct {
	// Package metadata
	Package Package `json:"package" yaml:"package"`
	// The specification for the packages build environment
	Environment apko_types.ImageConfiguration `json:"environment" yaml:"environment"`
	// Required: The list of pipelines that produce the package.
	Pipeline []Pipeline `json:"pipeline,omitempty" yaml:"pipeline,omitempty"`
	// Optional: The list of subpackages that this package also produces.
	Subpackages []Subpackage `json:"subpackages,omitempty" yaml:"subpackages,omitempty"`
	// Optional: An arbitrary list of data that can be used via templating in the
	// pipeline
	Data []RangeData `json:"data,omitempty" yaml:"data,omitempty"`
	// Optional: The update block determining how this package is auto updated
	Update Update `json:"update,omitempty" yaml:"update,omitempty"`
	// Optional: A map of arbitrary variables that can be used via templating in
	// the pipeline
	Vars map[string]string `json:"vars,omitempty" yaml:"vars,omitempty"`
	// Optional: A list of transformations to create for the builtin template
	// variables
	VarTransforms []VarTransforms `json:"var-transforms,omitempty" yaml:"var-transforms,omitempty"`
	// Optional: Deviations to the build
	Options map[string]BuildOption `json:"options,omitempty" yaml:"options,omitempty"`

	// Test section for the main package.
	Test Test `json:"test,omitempty" yaml:"test,omitempty"`
	// contains filtered or unexported fields
}

The root melange configuration

func ParseConfiguration

func ParseConfiguration(ctx context.Context, configurationFilePath string, opts ...ConfigurationParsingOption) (*Configuration, error)

ParseConfiguration returns a decoded build Configuration using the parsing options provided.

func (Configuration) GetVarsFromConfig

func (cfg Configuration) GetVarsFromConfig() (map[string]string, error)

Get variables from configuration and return them in a map

func (Configuration) Name

func (cfg Configuration) Name() string

Name returns a name for the configuration, using the package name.

func (Configuration) PackageURLs

func (cfg Configuration) PackageURLs(distro string) []string

PackageURLs returns a list of package URLs ("purls") for the given configuration. The first PURL is always the origin package, and any subsequent items are the PURLs for the Configuration's subpackages. For more information on PURLs, see https://github.com/package-url/purl-spec#purl.

func (Configuration) PerformVarSubstitutions

func (cfg Configuration) PerformVarSubstitutions(nw map[string]string) error

Perform variable substitutions from the configuration on a given map

func (Configuration) Root

func (cfg Configuration) Root() *yaml.Node

type ConfigurationParsingOption

type ConfigurationParsingOption func(*configOptions)

func WithDefaultCPU added in v0.5.4

func WithDefaultCPU(cpu string) ConfigurationParsingOption

func WithDefaultMemory added in v0.5.4

func WithDefaultMemory(memory string) ConfigurationParsingOption

func WithDefaultTimeout added in v0.5.4

func WithDefaultTimeout(timeout time.Duration) ConfigurationParsingOption

func WithEnvFileForParsing

func WithEnvFileForParsing(path string) ConfigurationParsingOption

WithEnvFileForParsing set the paths from which to read an environment file.

func WithFS

func WithFS(filesystem fs.FS) ConfigurationParsingOption

WithFS sets the fs.FS implementation to use. So far this FS is used only for reading the configuration file. If not provided, the default FS will be an os.DirFS created from the configuration file's containing directory.

func WithVarsFileForParsing

func WithVarsFileForParsing(path string) ConfigurationParsingOption

WithVarsFileForParsing sets the path to the vars file to use if the user wishes to populate the variables block from an external file.

type ContentsOption

type ContentsOption struct {
	Packages ListOption `yaml:"packages,omitempty"`
}

ContentsOption describes an optional deviation to an apko environment's contents block.

type Copyright struct {
	// Optional: The license paths, typically '*'
	Paths []string `json:"paths,omitempty" yaml:"paths,omitempty"`
	// Optional: Attestations of the license
	Attestation string `json:"attestation,omitempty" yaml:"attestation,omitempty"`
	// Required: The license for this package
	License string `json:"license" yaml:"license"`
}

type DataItems

type DataItems map[string]string

type Dependencies

type Dependencies struct {
	// Optional: List of runtime dependencies
	Runtime []string `json:"runtime,omitempty" yaml:"runtime,omitempty"`
	// Optional: List of packages provided
	Provides []string `json:"provides,omitempty" yaml:"provides,omitempty"`
	// Optional: List of replace objectives
	Replaces []string `json:"replaces,omitempty" yaml:"replaces,omitempty"`
	// Optional: An integer compared against other equal package provides used to
	// determine priority
	ProviderPriority int `json:"provider-priority,omitempty" yaml:"provider-priority,omitempty"`

	// List of self-provided dependencies found outside of lib directories
	// ("lib", "usr/lib", "lib64", or "usr/lib64").
	Vendored []string `json:"-" yaml:"-"`
}

func (*Dependencies) Summarize

func (dep *Dependencies) Summarize(ctx context.Context)

Summarize lists the dependencies that are configured in a dependency set.

type EnvironmentOption

type EnvironmentOption struct {
	Contents ContentsOption `yaml:"contents,omitempty"`
}

EnvironmentOption describes an optional deviation to an apko environment.

type ErrInvalidConfiguration

type ErrInvalidConfiguration struct {
	Problem error
}

func (ErrInvalidConfiguration) Error

func (e ErrInvalidConfiguration) Error() string

func (ErrInvalidConfiguration) Unwrap added in v0.5.2

func (e ErrInvalidConfiguration) Unwrap() error

type GitHubMonitor

type GitHubMonitor struct {
	// Org/repo for GitHub
	Identifier string `json:"identifier" yaml:"identifier"`
	// If the version in GitHub contains a prefix which should be ignored
	StripPrefix string `json:"strip-prefix,omitempty" yaml:"strip-prefix,omitempty"`
	// If the version in GitHub contains a suffix which should be ignored
	StripSuffix string `json:"strip-suffix,omitempty" yaml:"strip-suffix,omitempty"`
	// Filter to apply when searching tags on a GitHub repository
	// Deprecated: Use TagFilterPrefix instead
	TagFilter string `json:"tag-filter,omitempty" yaml:"tag-filter,omitempty"`
	// Prefix filter to apply when searching tags on a GitHub repository
	TagFilterPrefix string `json:"tag-filter-prefix,omitempty" yaml:"tag-filter-prefix,omitempty"`
	// Filter to apply when searching tags on a GitHub repository
	TagFilterContains string `json:"tag-filter-contains,omitempty" yaml:"tag-filter-contains,omitempty"`
	// Override the default of using a GitHub release to identify related tag to
	// fetch.  Not all projects use GitHub releases but just use tags
	UseTags bool `json:"use-tag,omitempty" yaml:"use-tag,omitempty"`
}

GitHubMonitor indicates using the GitHub API

type Input

type Input struct {
	// Optional: The human readable description of the input
	Description string `json:"description,omitempty"`
	// Optional: The default value of the input. Required when the input is.
	Default string `json:"default,omitempty"`
	// Optional: A toggle denoting whether the input is required or not
	Required bool `json:"required,omitempty"`
}

type ListOption

type ListOption struct {
	Add    []string `yaml:"add,omitempty"`
	Remove []string `yaml:"remove,omitempty"`
}

ListOption describes an optional deviation to a list, for example, a list of packages.

type Needs

type Needs struct {
	// A list of packages needed by this pipeline
	Packages []string
}

type Package

type Package struct {
	// The name of the package
	Name string `json:"name" yaml:"name"`
	// The version of the package
	Version string `json:"version" yaml:"version"`
	// The monotone increasing epoch of the package
	Epoch uint64 `json:"epoch" yaml:"epoch"`
	// A human readable description of the package
	Description string `json:"description,omitempty" yaml:"description,omitempty"`
	// The URL to the package's homepage
	URL string `json:"url,omitempty" yaml:"url,omitempty"`
	// Optional: The git commit of the package build configuration
	Commit string `json:"commit,omitempty" yaml:"commit,omitempty"`
	// List of target architectures for which this package should be build for
	TargetArchitecture []string `json:"target-architecture,omitempty" yaml:"target-architecture,omitempty"`
	// The list of copyrights for this package
	Copyright []Copyright `json:"copyright,omitempty" yaml:"copyright,omitempty"`
	// List of packages to depends on
	Dependencies Dependencies `json:"dependencies,omitempty" yaml:"dependencies,omitempty"`
	// Optional: Options that alter the packages behavior
	Options PackageOption `json:"options,omitempty" yaml:"options,omitempty"`
	// Optional: Executable scripts that run at various stages of the package
	// lifecycle, triggered by configurable events
	Scriptlets Scriptlets `json:"scriptlets,omitempty" yaml:"scriptlets,omitempty"`
	// Optional: enabling, disabling, and configuration of build checks
	Checks Checks `json:"checks,omitempty" yaml:"checks,omitempty"`

	// Optional: The amount of time to allow this build to take before timing out.
	Timeout time.Duration `json:"timeout,omitempty" yaml:"timeout,omitempty"`
	// Optional: Resources to allocate to the build.
	Resources *Resources `json:"resources,omitempty" yaml:"resources,omitempty"`
}

func (*Package) FullCopyright

func (p *Package) FullCopyright() string

FullCopyright returns the concatenated copyright expressions defined in the configuration file.

func (*Package) LicenseExpression

func (p *Package) LicenseExpression() string

LicenseExpression returns an SPDX license expression formed from the data in the copyright structs found in the conf. Its a simple OR for now.

func (Package) PackageURL

func (p Package) PackageURL(distro string) string

PackageURL returns the package URL ("purl") for the package. For more information, see https://github.com/package-url/purl-spec#purl.

type PackageOption

type PackageOption struct {
	// Optional: Signify this package as a virtual package which does not provide
	// any files, executables, libraries, etc... and is otherwise empty
	NoProvides bool `json:"no-provides" yaml:"no-provides"`
	// Optional: Mark this package as a self contained package that does not
	// depend on any other package
	NoDepends bool `json:"no-depends" yaml:"no-depends"`
	// Optional: Mark this package as not providing any executables
	NoCommands bool `json:"no-commands" yaml:"no-commands"`
}

type Pipeline

type Pipeline struct {
	// Optional: A user defined name for the pipeline
	Name string `json:"name,omitempty" yaml:"name,omitempty"`
	// Optional: A named reusable pipeline to run
	//
	// This can be either a pipeline builtin to melange, or a user defined named pipeline.
	// For example, to use a builtin melange pipeline:
	// 		uses: autoconf/make
	Uses string `json:"uses,omitempty" yaml:"uses,omitempty"`
	// Optional: Arguments passed to the reusable pipelines defined in `uses`
	With map[string]string `json:"with,omitempty" yaml:"with,omitempty"`
	// Optional: The command to run using the builder's shell (/bin/sh)
	Runs string `json:"runs,omitempty" yaml:"runs,omitempty"`
	// Optional: The list of pipelines to run.
	//
	// Each pipeline runs in it's own context that is not shared between other
	// pipelines. To share context between pipelines, nest a pipeline within an
	// existing pipeline. This can be useful when you wish to share common
	// configuration, such as an alternative `working-directory`.
	Pipeline []Pipeline `json:"pipeline,omitempty" yaml:"pipeline,omitempty"`
	// Optional: A map of inputs to the pipeline
	Inputs map[string]Input `json:"inputs,omitempty" yaml:"inputs,omitempty"`
	// Optional: Configuration to determine any explicit dependencies this pipeline may have
	Needs Needs `json:"needs,omitempty" yaml:"needs,omitempty"`
	// Optional: Labels to apply to the pipeline
	Label string `json:"label,omitempty" yaml:"label,omitempty"`
	// Optional: A condition to evaluate before running the pipeline
	If string `json:"if,omitempty" yaml:"if,omitempty"`
	// Optional: Assertions to evaluate whether the pipeline was successful
	Assertions PipelineAssertions `json:"assertions,omitempty" yaml:"assertions,omitempty"`
	// Optional: The working directory of the pipeline
	//
	// This defaults to the guests' build workspace (/home/build)
	WorkDir string `json:"working-directory,omitempty" yaml:"working-directory,omitempty"`
	// Optional: environment variables to override the apko environment
	Environment map[string]string `json:"environment,omitempty" yaml:"environment,omitempty"`
}

type PipelineAssertions

type PipelineAssertions struct {
	// The number (an int) of required steps that must complete successfully
	// within the asserted pipeline.
	RequiredSteps int `json:"required-steps,omitempty" yaml:"required-steps,omitempty"`
}

type RangeData

type RangeData struct {
	Name  string    `json:"name" yaml:"name"`
	Items DataItems `json:"items" yaml:"items"`
}

type ReleaseMonitor

type ReleaseMonitor struct {
	// Required: ID number for release monitor
	Identifier int `json:"identifier" yaml:"identifier"`
	// If the version in release monitor contains a prefix which should be ignored
	StripPrefix string `json:"strip-prefix,omitempty" yaml:"strip-prefix,omitempty"`
	// If the version in release monitor contains a suffix which should be ignored
	StripSuffix string `json:"strip-suffix,omitempty" yaml:"strip-suffix,omitempty"`
}

ReleaseMonitor indicates using the API for https://release-monitoring.org/

type Resources added in v0.5.4

type Resources struct {
	CPU    string `json:"cpu,omitempty" yaml:"cpu,omitempty"`
	Memory string `json:"memory,omitempty" yaml:"memory,omitempty"`
}

type SBOM

type SBOM struct {
	// Optional: The language of the generated SBOM
	Language string `json:"language" yaml:"language"`
}

type Scriptlets

type Scriptlets struct {
	// Optional: A script to run on a custom trigger
	Trigger struct {
		// Optional: The script to run
		Script string `json:"script,omitempty"`
		// Optional: The list of paths to monitor to trigger the script
		Paths []string `json:"paths,omitempty"`
	} `json:"trigger,omitempty" yaml:"trigger,omitempty"`

	// Optional: The script to run pre install. The script should contain the
	// shebang interpreter.
	PreInstall string `json:"pre-install,omitempty" yaml:"pre-install,omitempty"`
	// Optional: The script to run post install. The script should contain the
	// shebang interpreter.
	PostInstall string `json:"post-install,omitempty" yaml:"post-install,omitempty"`
	// Optional: The script to run before uninstalling. The script should contain
	// the shebang interpreter.
	PreDeinstall string `json:"pre-deinstall,omitempty" yaml:"pre-deinstall,omitempty"`
	// Optional: The script to run after uninstalling. The script should contain
	// the shebang interpreter.
	PostDeinstall string `json:"post-deinstall,omitempty" yaml:"post-deinstall,omitempty"`
	// Optional: The script to run before upgrading. The script should contain
	// the shebang interpreter.
	PreUpgrade string `json:"pre-upgrade,omitempty" yaml:"pre-upgrade,omitempty"`
	// Optional: The script to run after upgrading. The script should contain the
	// shebang interpreter.
	PostUpgrade string `json:"post-upgrade,omitempty" yaml:"post-upgrade,omitempty"`
}

type Subpackage

type Subpackage struct {
	// Optional: A conditional statement to evaluate for the subpackage
	If string `json:"if,omitempty" yaml:"if,omitempty"`
	// Optional: The iterable used to generate multiple subpackages
	Range string `json:"range,omitempty" yaml:"range,omitempty"`
	// Required: Name of the subpackage
	Name string `json:"name" yaml:"name"`
	// Optional: The list of pipelines that produce subpackage.
	Pipeline []Pipeline `json:"pipeline,omitempty" yaml:"pipeline,omitempty"`
	// Optional: List of packages to depend on
	Dependencies Dependencies `json:"dependencies,omitempty" yaml:"dependencies,omitempty"`
	// Optional: Options that alter the packages behavior
	Options    PackageOption `json:"options,omitempty" yaml:"options,omitempty"`
	Scriptlets Scriptlets    `json:"scriptlets,omitempty" yaml:"scriptlets,omitempty"`
	// Optional: The human readable description of the subpackage
	Description string `json:"description,omitempty" yaml:"description,omitempty"`
	// Optional: The URL to the package's homepage
	URL string `json:"url,omitempty" yaml:"url,omitempty"`
	// Optional: The git commit of the subpackage build configuration
	Commit string `json:"commit,omitempty" yaml:"commit,omitempty"`
	// Optional: enabling, disabling, and configuration of build checks
	Checks Checks `json:"checks,omitempty" yaml:"checks,omitempty"`
	// Test section for the subpackage.
	Test Test `json:"test,omitempty" yaml:"test,omitempty"`
}

func (Subpackage) PackageURL

func (spkg Subpackage) PackageURL(distro, packageVersionWithRelease string) string

PackageURL returns the package URL ("purl") for the subpackage. For more information, see https://github.com/package-url/purl-spec#purl.

type Test added in v0.5.4

type Test struct {
	// Additional Environment necessary for test.
	// Environment.Contents.Packages automatically get
	// package.dependencies.runtime added to it. So, if your test needs
	// no additional packages, you can leave it blank.
	Environment apko_types.ImageConfiguration `json:"environment" yaml:"environment"`

	// Required: The list of pipelines that test the produced package.
	Pipeline []Pipeline `json:"pipeline" yaml:"pipeline"`
}

type Update

type Update struct {
	// Toggle if updates should occur
	Enabled bool `json:"enabled" yaml:"enabled"`
	// Indicates that this package should be manually updated, usually taking
	// care over special version numbers
	Manual bool `json:"manual,omitempty" yaml:"manual"`
	// Indicate that an update to this package requires an epoch bump of
	// downstream dependencies, e.g. golang, java
	Shared bool `json:"shared,omitempty" yaml:"shared,omitempty"`
	// Override the version separator if it is nonstandard
	VersionSeparator string `json:"version-separator,omitempty" yaml:"version-separator,omitempty"`
	// A slice of regex patterns to match an upstream version and ignore
	IgnoreRegexPatterns []string `json:"ignore-regex-patterns,omitempty" yaml:"ignore-regex-patterns,omitempty"`
	// The configuration block for updates tracked via release-monitoring.org
	ReleaseMonitor *ReleaseMonitor `json:"release-monitor,omitempty" yaml:"release-monitor,omitempty"`
	// The configuration block for updates tracked via the Github API
	GitHubMonitor *GitHubMonitor `json:"github,omitempty" yaml:"github,omitempty"`
	// The configuration block for transforming the `package.version` into an APK version
	VersionTransform []VersionTransform `json:"version-transform,omitempty" yaml:"version-transform,omitempty"`
}

Update provides information used to describe how to keep the package up to date

type VarTransforms

type VarTransforms struct {
	// Required: The original template variable.
	//
	// Example: ${{package.version}}
	From string `json:"from" yaml:"from"`
	// Required: The regular expression to match against the `from` variable
	Match string `json:"match" yaml:"match"`
	// Required: The repl to replace on all `match` matches
	Replace string `json:"replace" yaml:"replace"`
	// Required: The name of the new variable to create
	//
	// Example: mangeled-package-version
	To string `json:"to" yaml:"to"`
}

type VersionTransform

type VersionTransform struct {
	// Required: The regular expression to match against the `package.version` variable
	Match string `json:"match" yaml:"match"`
	// Required: The repl to replace on all `match` matches
	Replace string `json:"replace" yaml:"replace"`
}

VersionTransform allows mapping the package version to an APK version

Jump to

Keyboard shortcuts

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