packmanager

package
v0.6.7-92-g2828af2 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2023 License: BSD-3-Clause Imports: 11 Imported by: 1

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

View Source
const UmbrellaFormat pack.PackageFormat = "umbrella"

Variables

View Source
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 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

func WithDefaultUmbrellaManagerInContext(ctx context.Context) (context.Context, error)

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 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 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 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 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 (*PackOptions) Args added in v0.5.2

func (popts *PackOptions) Args() []string

Args returns the arguments to pass 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) KernelVersion added in v0.5.0

func (popts *PackOptions) KernelVersion() string

KernelVersion returns the version of the kernel

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

	// Prune packages from the host machine
	Prune(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) All added in v0.7.0

func (query *Query) All() bool

All returns the value set for all.

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) Fields added in v0.6.0

func (query *Query) Fields() map[string]interface{}

func (*Query) Name added in v0.6.0

func (query *Query) Name() string

Name specifies the name of the package

func (*Query) NoManifestPackage

func (query *Query) NoManifestPackage() bool

func (*Query) NoOCIPackage

func (query *Query) NoOCIPackage() bool

func (*Query) Source added in v0.6.0

func (query *Query) Source() string

Source specifies where the origin of the package

func (Query) String added in v0.6.0

func (cq Query) String() string

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

func (*Query) UseCache added in v0.6.0

func (query *Query) UseCache() bool

UseCache indicates whether the package manager should use any existing cache.

func (*Query) Version added in v0.6.0

func (query *Query) Version() string

Version specifies the version of 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 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 WithCache added in v0.6.0

func WithCache(useCache bool) QueryOption

WithCache sets whether to use local caching 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 WithNoManifestPackage

func WithNoManifestPackage(noManifestPackage bool) QueryOption

func WithNoOCIPackage

func WithNoOCIPackage(noOCIPackage bool) QueryOption

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) Format

func (u UmbrellaManager) Format() pack.PackageFormat

func (UmbrellaManager) From

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) Prune

func (u UmbrellaManager) Prune(ctx context.Context, qopts ...QueryOption) error

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

func (UmbrellaManager) Unpack added in v0.6.7

func (u UmbrellaManager) Unpack(ctx context.Context, source pack.Package, opts ...UnpackOption) ([]component.Component, error)

func (UmbrellaManager) Update

func (u UmbrellaManager) Update(ctx context.Context) 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.

Jump to

Keyboard shortcuts

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