Documentation ¶
Overview ¶
SPDX-License-Identifier: BSD-3-Clause Copyright (c) 2022, Unikraft GmbH and The KraftKit Authors. Licensed under the BSD-3-Clause License (the "License"). You may not use this file expect in compliance with the License.
SPDX-License-Identifier: BSD-3-Clause Copyright (c) 2022, Unikraft GmbH and The KraftKit Authors. Licensed under the BSD-3-Clause License (the "License"). You may not use this file except in compliance with the License.
SPDX-License-Identifier: BSD-3-Clause Copyright (c) 2022, Unikraft GmbH and The KraftKit Authors. Licensed under the BSD-3-Clause License (the "License"). You may not use this file except in compliance with the License.
SPDX-License-Identifier: BSD-3-Clause Copyright (c) 2022, Unikraft GmbH and The KraftKit Authors. Licensed under the BSD-3-Clause License (the "License"). You may not use this file except in compliance with the License.
SPDX-License-Identifier: BSD-3-Clause Copyright (c) 2022, Unikraft GmbH and The KraftKit Authors. Licensed under the BSD-3-Clause License (the "License"). You may not use this file except in compliance with the License.
SPDX-License-Identifier: BSD-3-Clause Copyright (c) 2022, Unikraft GmbH and The KraftKit Authors. Licensed under the BSD-3-Clause License (the "License"). You may not use this file except in compliance with the License.
Index ¶
- Constants
- Variables
- func InitUmbrellaManager(ctx context.Context, constructors []func(*UmbrellaManager) error) error
- func MergeStrategyNames() []string
- func PackageManagers() (map[pack.PackageFormat]PackageManager, error)
- func WithDefaultUmbrellaManagerInContext(ctx context.Context) (context.Context, error)
- func WithManagerInContext(ctx context.Context, pm PackageManager) context.Context
- func WithPackageManager(ctx context.Context, pm PackageManager) context.Context
- type MergeStrategy
- type NewManagerConstructor
- type PackOption
- func PackAppSourceFiles(pack bool) PackOption
- func PackArgs(args ...string) PackOption
- func PackInitrd(initrd string) PackOption
- func PackKConfig(kconfig bool) PackOption
- func PackKernelDbg(dbg bool) PackOption
- func PackKernelLibraryIntermediateObjects(pack bool) PackOption
- func PackKernelLibraryObjects(pack bool) PackOption
- func PackKernelSourceFiles(pack bool) PackOption
- func PackLabels(labels map[string]string) PackOption
- func PackMergeStrategy(strategy MergeStrategy) PackOption
- func PackName(name string) PackOption
- func PackOutput(output string) PackOption
- func PackWithEnvs(envs []string) PackOption
- func PackWithKernelVersion(version string) PackOption
- type PackOptions
- func (popts *PackOptions) Args() []string
- func (popts *PackOptions) Env() []string
- func (popts *PackOptions) Initrd() string
- func (popts *PackOptions) KernelDbg() bool
- func (popts *PackOptions) KernelVersion() string
- func (popts *PackOptions) Labels() map[string]string
- func (popts *PackOptions) MergeStrategy() MergeStrategy
- func (popts *PackOptions) Name() string
- func (popts *PackOptions) Output() string
- func (popts *PackOptions) PackAppSourceFiles() bool
- func (popts *PackOptions) PackKConfig() bool
- func (popts *PackOptions) PackKernelLibraryIntermediateObjects() bool
- func (popts *PackOptions) PackKernelLibraryObjects() bool
- func (popts *PackOptions) PackKernelSourceFiles() bool
- type PackageManager
- type Query
- func (query *Query) All() bool
- func (query *Query) Architecture() string
- func (query *Query) Auths() map[string]config.AuthConfig
- func (query *Query) Fields() map[string]interface{}
- func (query *Query) KConfig() []string
- func (query *Query) Local() bool
- func (query *Query) Name() string
- func (query *Query) Platform() string
- func (query *Query) Remote() bool
- func (query *Query) Source() string
- func (cq Query) String() string
- func (query *Query) Types() []unikraft.ComponentType
- func (query *Query) Version() string
- type QueryOption
- func WithAll(all bool) QueryOption
- func WithArchitecture(arch string) QueryOption
- func WithAuthConfig(auths map[string]config.AuthConfig) QueryOption
- func WithKConfig(kConfig []string) QueryOption
- func WithLocal(local bool) QueryOption
- func WithName(name string) QueryOption
- func WithPlatform(platform string) QueryOption
- func WithRemote(remote bool) QueryOption
- func WithSource(source string) QueryOption
- func WithTypes(types ...unikraft.ComponentType) QueryOption
- func WithVersion(version string) QueryOption
- type UmbrellaManager
- func (u UmbrellaManager) AddSource(ctx context.Context, source string) error
- func (u UmbrellaManager) Catalog(ctx context.Context, qopts ...QueryOption) ([]pack.Package, error)
- func (u UmbrellaManager) Delete(ctx context.Context, qopts ...QueryOption) error
- func (u UmbrellaManager) Format() pack.PackageFormat
- func (u UmbrellaManager) From(sub pack.PackageFormat) (PackageManager, error)
- func (u UmbrellaManager) IsCompatible(ctx context.Context, source string, qopts ...QueryOption) (PackageManager, bool, error)
- func (u UmbrellaManager) Pack(ctx context.Context, source component.Component, opts ...PackOption) ([]pack.Package, error)
- func (u *UmbrellaManager) PackageManagers() map[pack.PackageFormat]PackageManager
- func (u *UmbrellaManager) RegisterPackageManager(ctxk pack.PackageFormat, constructor NewManagerConstructor, opts ...any) error
- func (u UmbrellaManager) RemoveSource(ctx context.Context, source string) error
- func (u UmbrellaManager) SetSources(ctx context.Context, sources ...string) error
- func (u UmbrellaManager) Unpack(ctx context.Context, source pack.Package, opts ...UnpackOption) ([]component.Component, error)
- func (u UmbrellaManager) Update(ctx context.Context) error
- type UnpackOption
- type UnpackOptions
Constants ¶
const ( // The 'exit' strategy is used to error-out and indicate that no strategy was // provided and that further operations cannot be completed. StrategyExit = MergeStrategy("exit") // The 'overwrite' strategy removes the existing package with the same // canonical name and replaces it with a new package entirely. StrategyOverwrite = MergeStrategy("overwrite") // The 'merge' strategy attempts to combine an existing package with new // artifacts such the updated package contains the artifacts from before plus // the artifacts. // // This is useful in contexts, for example, where packages represents an // application which has multiple targets and a new target is added to the // already packaged application. StrategyMerge = MergeStrategy("merge") // The 'prompt' strategy is an "unlisted" strategy that's used in TTY contexts // where the user is given the opportunity to decide the merge strategy before // the package operation is performed. The result of this decision should // yield one of the above merge strategies. StrategyPrompt = MergeStrategy("prompt") )
const UmbrellaFormat pack.PackageFormat = "umbrella"
Variables ¶
var ( // G is an alias for FromContext. // // We may want to define this locally to a package to get package tagged // package manager. G = FromContext // PM is the system-access umbrella package manager. PM = UmbrellaManager{} )
Functions ¶
func InitUmbrellaManager ¶ added in v0.6.7
func InitUmbrellaManager(ctx context.Context, constructors []func(*UmbrellaManager) error) error
InitUmbrellaManager creates the instance of the umbrella manager singleton. It allows us to do dependency injection for package manager constructors.
func MergeStrategyNames ¶ added in v0.7.0
func MergeStrategyNames() []string
MergeStrategyNames returns the string representation of all possible package merge strategies.
func PackageManagers ¶
func PackageManagers() (map[pack.PackageFormat]PackageManager, error)
PackageManagers returns all package managers registered with the umbrella package manager.
func WithDefaultUmbrellaManagerInContext ¶ added in v0.6.7
WithDefaultUmbrellaManagerInContext returns a context containing the default umbrella package manager.
func WithManagerInContext ¶ added in v0.6.7
func WithManagerInContext(ctx context.Context, pm PackageManager) context.Context
WithManagerInContext inserts a package manager into a context.
func WithPackageManager ¶ added in v0.2.0
func WithPackageManager(ctx context.Context, pm PackageManager) context.Context
WithPackageManager returns a new context with the provided package manager.
Types ¶
type MergeStrategy ¶ added in v0.7.0
type MergeStrategy string
MergeStrategy is a method to describe how to approach creating packages that have the same canonical name. This is useful when deciding whether an existing package simply needs to be updated to include additional artifacts, e.g. targets, or whether the package should be overwritten because it is no longer required.
func MergeStrategies ¶ added in v0.7.0
func MergeStrategies() []MergeStrategy
MergeStrategies returns the list of possible package merge strategies.
func (MergeStrategy) String ¶ added in v0.7.0
func (strategy MergeStrategy) String() string
String implements fmt.Stringer
type NewManagerConstructor ¶ added in v0.5.0
type NewManagerConstructor func(context.Context, ...any) (PackageManager, error)
NewManagerConstructor represents the prototype that all implementing package managers must use during their instantiation. This standardizes their input and output during "construction", particularly providing access to a referenceable context with which they can access (within the context of KraftKit) the logging, IOStreams and Config subsystems.
type PackOption ¶ added in v0.4.0
type PackOption func(*PackOptions)
PackOption is an option function which is used to modify PackOptions.
func PackAppSourceFiles ¶ added in v0.4.0
func PackAppSourceFiles(pack bool) PackOption
PackAppSourceFiles marks to include application source files
func PackArgs ¶ added in v0.5.2
func PackArgs(args ...string) PackOption
PackArgs sets the arguments to be passed to the application.
func PackInitrd ¶ added in v0.4.0
func PackInitrd(initrd string) PackOption
PackInitrd includes the provided path to an initrd file in the package.
func PackKConfig ¶ added in v0.4.0
func PackKConfig(kconfig bool) PackOption
PackKConfig marks to include the kconfig `.config` file into the package.
func PackKernelDbg ¶ added in v0.7.4
func PackKernelDbg(dbg bool) PackOption
PackKernelDbg includes the debug kernel in the package.
func PackKernelLibraryIntermediateObjects ¶ added in v0.4.0
func PackKernelLibraryIntermediateObjects(pack bool) PackOption
PackKernelLibraryIntermediateObjects marks to include intermediate library object files, e.g. libnolibc/errno.o
func PackKernelLibraryObjects ¶ added in v0.4.0
func PackKernelLibraryObjects(pack bool) PackOption
PackKernelLibraryObjects marks to include library object files, e.g. nolibc.o
func PackKernelSourceFiles ¶ added in v0.4.0
func PackKernelSourceFiles(pack bool) PackOption
PackKernelSourceFiles marks that all source files which make up the build from the Unikraft build side are to be included. Including these files will enable a reproducible build.
func PackLabels ¶ added in v0.9.0
func PackLabels(labels map[string]string) PackOption
PackLabels adds the labels to the package.
func PackMergeStrategy ¶ added in v0.7.0
func PackMergeStrategy(strategy MergeStrategy) PackOption
PackMergeStrategy sets the mechanism to use when an existing package of the same name exists.
func PackName ¶ added in v0.6.5
func PackName(name string) PackOption
PackName sets the name of the package.
func PackOutput ¶ added in v0.4.0
func PackOutput(output string) PackOption
PackOutput sets the location of the output artifact package.
func PackWithEnvs ¶ added in v0.8.3
func PackWithEnvs(envs []string) PackOption
PackWithEnv adds the environment variables to the package.
func PackWithKernelVersion ¶ added in v0.5.0
func PackWithKernelVersion(version string) PackOption
PackWithKernelVersion sets the version of the Unikraft core.
type PackOptions ¶ added in v0.4.0
type PackOptions struct {
// contains filtered or unexported fields
}
PackOptions contains the list of options which can be set when packaging a component.
func NewPackOptions ¶ added in v0.7.0
func NewPackOptions() *PackOptions
NewPackOptions returns an instantiated *NewPackOptions with default configuration options values.
func (*PackOptions) Args ¶ added in v0.5.2
func (popts *PackOptions) Args() []string
Args returns the arguments to pass to the kernel.
func (*PackOptions) Env ¶ added in v0.8.3
func (popts *PackOptions) Env() []string
Env returns the environment variables to be passed to the kernel.
func (*PackOptions) Initrd ¶ added in v0.4.0
func (popts *PackOptions) Initrd() string
Initrd returns the path of the initrd file that should be packaged.
func (*PackOptions) KernelDbg ¶ added in v0.7.4
func (popts *PackOptions) KernelDbg() bool
PackKernelDbg returns return whether to package the debug kernel.
func (*PackOptions) KernelVersion ¶ added in v0.5.0
func (popts *PackOptions) KernelVersion() string
KernelVersion returns the version of the kernel
func (*PackOptions) Labels ¶ added in v0.9.0
func (popts *PackOptions) Labels() map[string]string
Labels returns the labels to be added to the package.
func (*PackOptions) MergeStrategy ¶ added in v0.7.0
func (popts *PackOptions) MergeStrategy() MergeStrategy
MergeStrategy ...
func (*PackOptions) Name ¶ added in v0.6.5
func (popts *PackOptions) Name() string
Name returns the name of the package.
func (*PackOptions) Output ¶ added in v0.4.0
func (popts *PackOptions) Output() string
Output returns the location of the package.
func (*PackOptions) PackAppSourceFiles ¶ added in v0.4.0
func (popts *PackOptions) PackAppSourceFiles() bool
PackAppSourceFiles returns whether the application source files should be packaged.
func (*PackOptions) PackKConfig ¶ added in v0.4.0
func (popts *PackOptions) PackKConfig() bool
PackKConfig returns whether the .config file should be packaged.
func (*PackOptions) PackKernelLibraryIntermediateObjects ¶ added in v0.4.0
func (popts *PackOptions) PackKernelLibraryIntermediateObjects() bool
PackKernelLibraryIntermediateObjects returns whether to package intermediate kernel library object files.
func (*PackOptions) PackKernelLibraryObjects ¶ added in v0.4.0
func (popts *PackOptions) PackKernelLibraryObjects() bool
PackKernelLibraryObjects returns whether to package kernel library objects.
func (*PackOptions) PackKernelSourceFiles ¶ added in v0.4.0
func (popts *PackOptions) PackKernelSourceFiles() bool
PackKernelSourceFiles returns the whether to package kernel source files.
type PackageManager ¶
type PackageManager interface { // Update retrieves and stores locally a cache of the upstream registry. Update(context.Context) error // Pack turns the provided component into the distributable package. Since // components can comprise of other components, it is possible to return more // than one package. It is possible to disable this and "flatten" a component // into a single package by setting a relevant `pack.PackOption`. Pack(context.Context, component.Component, ...PackOption) ([]pack.Package, error) // Unpack turns a given package into a usable component. Since a package can // compromise of a multiple components, it is possible to return multiple // components. Unpack(context.Context, pack.Package, ...UnpackOption) ([]component.Component, error) // Catalog returns all packages known to the manager via given query Catalog(context.Context, ...QueryOption) ([]pack.Package, error) // Set the list of sources for the package manager SetSources(context.Context, ...string) error // Add a source to the package manager AddSource(context.Context, string) error // Delete package(s) from the package manager Delete(context.Context, ...QueryOption) error // Remove a source from the package manager RemoveSource(context.Context, string) error // IsCompatible checks whether the provided source is compatible with the // package manager IsCompatible(context.Context, string, ...QueryOption) (PackageManager, bool, error) // From is used to retrieve a sub-package manager. For now, this is a small // hack used for the umbrella. From(pack.PackageFormat) (PackageManager, error) // Format returns the name of the implementation. Format() pack.PackageFormat }
func FromContext ¶ added in v0.2.0
func FromContext(ctx context.Context) PackageManager
FromContext returns the package manager in the context, or access to the umbrella package manager which iterates over all registered package managers.
type Query ¶ added in v0.6.0
type Query struct {
// contains filtered or unexported fields
}
Query is the request structure with associated attributes which are used to search the package manager's catalog
func NewQuery ¶ added in v0.6.0
func NewQuery(qopts ...QueryOption) *Query
NewQuery returns the finalized query given the provided options.
func (*Query) Architecture ¶ added in v0.7.0
Architecture specifies the architecture of the package
func (*Query) Auths ¶ added in v0.6.0
func (query *Query) Auths() map[string]config.AuthConfig
Auth returns authentication configuration for a given domain or nil if the domain does not have (or require) any authentication.
func (*Query) Local ¶ added in v0.7.6
Local indicates whether the package manager should use local manifests when making its query.
func (*Query) Remote ¶ added in v0.7.6
Remote indicates whether the package manager should use remote manifests when making its query.
func (*Query) Types ¶ added in v0.6.0
func (query *Query) Types() []unikraft.ComponentType
Types specifies the associated list of possible types for the package
type QueryOption ¶ added in v0.6.0
type QueryOption func(*Query)
QueryOption is a method-option which sets a specific query parameter.
func WithAll ¶ added in v0.7.0
func WithAll(all bool) QueryOption
func WithArchitecture ¶ added in v0.7.0
func WithArchitecture(arch string) QueryOption
WithArchitecture sets the query parameter for the architecture of the package.
func WithAuthConfig ¶ added in v0.6.0
func WithAuthConfig(auths map[string]config.AuthConfig) QueryOption
WithAuthConfig sets the the required authorization for when making the query.
func WithKConfig ¶ added in v0.7.0
func WithKConfig(kConfig []string) QueryOption
WithKconfig sets the query parameter for the list of configuration options of the package.
func WithLocal ¶ added in v0.7.6
func WithLocal(local bool) QueryOption
WithLocal sets whether to use local manifests when making the query.
func WithName ¶ added in v0.6.0
func WithName(name string) QueryOption
WithName sets the query parameter for the name of the package.
func WithPlatform ¶ added in v0.7.0
func WithPlatform(platform string) QueryOption
WithPlatform sets the query parameter for the platform of the package.
func WithRemote ¶ added in v0.7.6
func WithRemote(remote bool) QueryOption
WithRemote sets whether to use remote manifests when making the query.
func WithSource ¶ added in v0.6.0
func WithSource(source string) QueryOption
WithSource sets the query parameter for the origin source of the package.
func WithTypes ¶ added in v0.6.0
func WithTypes(types ...unikraft.ComponentType) QueryOption
WithTypes sets the query parameter for the specific Unikraft types to search for.
func WithVersion ¶ added in v0.6.0
func WithVersion(version string) QueryOption
WithVersion sets the query parameter for the version of the package.
type UmbrellaManager ¶
type UmbrellaManager struct {
// contains filtered or unexported fields
}
UmbrellaManager is an ad-hoc package manager capable of cross managing any registered package managers.
var UmbrellaInstance *UmbrellaManager
UmbrellaInstance is a singleton of our umbrella package manager.
func NewUmbrellaManager ¶ added in v0.4.0
func NewUmbrellaManager(ctx context.Context, constructors []func(*UmbrellaManager) error) (*UmbrellaManager, error)
NewUmbrellaManager returns a `PackageManager` which can be used to manipulate multiple `PackageManager`s. The purpose is to be able to package, unpackage, search and generally manipulate packages of multiple types simultaneously. The user can pass a slice of constructors to determine which package managers are to be included.
func (UmbrellaManager) AddSource ¶
func (u UmbrellaManager) AddSource(ctx context.Context, source string) error
func (UmbrellaManager) Catalog ¶
func (u UmbrellaManager) Catalog(ctx context.Context, qopts ...QueryOption) ([]pack.Package, error)
func (UmbrellaManager) Delete ¶ added in v0.7.0
func (u UmbrellaManager) Delete(ctx context.Context, qopts ...QueryOption) error
func (UmbrellaManager) Format ¶
func (u UmbrellaManager) Format() pack.PackageFormat
func (UmbrellaManager) From ¶
func (u UmbrellaManager) From(sub pack.PackageFormat) (PackageManager, error)
func (UmbrellaManager) IsCompatible ¶
func (u UmbrellaManager) IsCompatible(ctx context.Context, source string, qopts ...QueryOption) (PackageManager, bool, error)
func (UmbrellaManager) Pack ¶ added in v0.6.7
func (u UmbrellaManager) Pack(ctx context.Context, source component.Component, opts ...PackOption) ([]pack.Package, error)
func (*UmbrellaManager) PackageManagers ¶ added in v0.6.7
func (u *UmbrellaManager) PackageManagers() map[pack.PackageFormat]PackageManager
func (*UmbrellaManager) RegisterPackageManager ¶ added in v0.6.7
func (u *UmbrellaManager) RegisterPackageManager(ctxk pack.PackageFormat, constructor NewManagerConstructor, opts ...any) error
func (UmbrellaManager) RemoveSource ¶
func (u UmbrellaManager) RemoveSource(ctx context.Context, source string) error
func (UmbrellaManager) SetSources ¶ added in v0.6.7
func (u UmbrellaManager) SetSources(ctx context.Context, sources ...string) error
type UnpackOption ¶ added in v0.4.0
type UnpackOption func(*UnpackOptions) error
UnpackOption is an option function which is used to modify UnpackOptions.
func WithUnpackWorkdir ¶ added in v0.4.0
func WithUnpackWorkdir(workdir string) UnpackOption
WithUnpackWorkdir sets the directory to unpack the package to
type UnpackOptions ¶ added in v0.4.0
type UnpackOptions struct {
// contains filtered or unexported fields
}
UnpackOptions contains the list of options which can be used to unpackage an a component.