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 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 expect in compliance with the License.
SPDX-License-Identifier: BSD-3-Clause Copyright (c) 2023, 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: Apache-2.0
Copyright 2020 The Compose Specification Authors. Copyright 2022 Unikraft GmbH. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at:
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
SPDX-License-Identifier: Apache-2.0
Copyright 2020 The Compose Specification Authors. Copyright 2022 Unikraft GmbH. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at:
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- Constants
- Variables
- func IsWorkdirInitialized(dir string) bool
- func ParseYAML(source []byte) (map[string]interface{}, error)
- func Transform(ctx context.Context, source interface{}, target interface{}, ...) error
- type Application
- func NewApplicationFromInterface(ctx context.Context, iface map[string]interface{}, popts *ProjectOptions) (Application, error)
- func NewApplicationFromKernel(ctx context.Context, elfPath, configFile, kraftFile string) (Application, error)
- func NewApplicationFromOptions(aopts ...ApplicationOption) (Application, error)
- func NewProjectFromOptions(ctx context.Context, opts ...ProjectOption) (Application, error)
- type ApplicationOption
- func WithCommand(command ...string) ApplicationOption
- func WithConfiguration(config ...*kconfig.KeyValue) ApplicationOption
- func WithEnv(env map[string]string) ApplicationOption
- func WithExtensions(extensions component.Extensions) ApplicationOption
- func WithFilename(filename string) ApplicationOption
- func WithKraftfile(kraftfile *Kraftfile) ApplicationOption
- func WithLibraries(libraries map[string]*lib.LibraryConfig) ApplicationOption
- func WithName(name string) ApplicationOption
- func WithOutDir(outDir string) ApplicationOption
- func WithRootfs(rootfs string) ApplicationOption
- func WithRuntime(rt *runtime.Runtime) ApplicationOption
- func WithSource(source string) ApplicationOption
- func WithTargets(targets ...target.Target) ApplicationOption
- func WithTemplate(template *template.TemplateConfig) ApplicationOption
- func WithUnikraft(unikraft *core.UnikraftConfig) ApplicationOption
- func WithVersion(version string) ApplicationOption
- func WithVolumes(volumes ...*volume.VolumeConfig) ApplicationOption
- func WithWorkingDir(workingDir string) ApplicationOption
- type BuildOption
- type BuildOptions
- type ComponentInfoRecord
- type Kraftfile
- type ProjectOption
- func WithProjectConfig(config []string) ProjectOption
- func WithProjectDefaultKraftfiles() ProjectOption
- func WithProjectInterpolation(interpolation bool) ProjectOption
- func WithProjectKraftfile(file string) ProjectOption
- func WithProjectKraftfileFromBytes(content []byte) ProjectOption
- func WithProjectName(name string) ProjectOption
- func WithProjectNormalization(normalization bool) ProjectOption
- func WithProjectResolvedPaths(resolve bool) ProjectOption
- func WithProjectSkipValidation(skipValidation bool) ProjectOption
- func WithProjectWorkdir(workdir string) ProjectOption
- type ProjectOptions
- func (popts *ProjectOptions) AddKraftfile(file string) error
- func (popts *ProjectOptions) AddKraftfileFromBytes(content []byte) error
- func (popts *ProjectOptions) GetProjectName() (string, bool)
- func (popts *ProjectOptions) LookupConfig(key string) (string, bool)
- func (popts *ProjectOptions) RelativePath(path string) string
- func (popts *ProjectOptions) SetProjectName(name string, imperativelySet bool)
- func (popts *ProjectOptions) Workdir() (string, error)
- type Transformer
- type TransformerFunc
Constants ¶
const (
DefaultConfigFile = ".config"
)
Variables ¶
var DefaultFileNames = []string{
"kraft.yaml",
"kraft.yml",
"Kraftfile.yml",
"Kraftfile.yaml",
"Kraftfile",
}
DefaultFileNames defines the kraft file names for auto-discovery (in order of preference)
var ErrNoKraftfile = fmt.Errorf("no Kraftfile specified")
ErrNoKraftfile is thrown when a project is instantiated at a directory without a recognizable Kraftfile.
Functions ¶
func IsWorkdirInitialized ¶ added in v0.2.0
IsWorkdirInitialized provides a quick check to determine if whether one of the supported project files (Kraftfiles) is present within a provided working directory.
Types ¶
type Application ¶
type Application interface { component.Component // WorkingDir returns the path to the application's working directory WorkingDir() string // Unikraft returns the application's unikraft configuration Unikraft(context.Context) *core.UnikraftConfig // OutDir returns the path to the application's output directory OutDir() string // Template returns the application's template Template() *template.TemplateConfig // Runtime returns the application's runtime. Runtime() *runtime.Runtime // Libraries returns the application libraries' configurations Libraries(ctx context.Context) (map[string]*lib.LibraryConfig, error) // Targets returns the application's targets Targets() []target.Target // Rootfs is the desired path containing the filesystem that will be mounted // as the root filesystem. This can either be an initramdisk or a volume. Rootfs() string // SetRootfs sets the root filesystem path for the application to the given // value path. SetRootfs(string) // Command is the list of arguments passed to the application's runtime. Command() []string // Extensions returns the application's extensions Extensions() component.Extensions // Kraftfile returns the application's kraft configuration file Kraftfile() *Kraftfile // MergeTemplate merges the application's configuration with the given // configuration MergeTemplate(context.Context, Application) (Application, error) // IsConfigured returns a boolean to indicate whether the application has been // previously configured. This is deteremined by finding a non-empty // `.config` file within the application's source directory IsConfigured(target.Target) bool // MakeArgs returns the populated `core.MakeArgs` based on the contents of the // instantiated `application`. This information can be passed directly // to Unikraft's build system. MakeArgs(context.Context, target.Target) (*core.MakeArgs, error) // Make is a method which invokes Unikraft's build system. You can pass in // make options based on the `make` package. Ultimately, this is an abstract // method which will be used by a number of well-known make command goals by // Unikraft's build system. Make(context.Context, target.Target, ...make.MakeOption) error // SyncConfig updates the configuration SyncConfig(context.Context, target.Target, ...make.MakeOption) error // Configure updates the configuration Configure(context.Context, target.Target, kconfig.KeyValueMap, ...make.MakeOption) error // Prepare the application Prepare(context.Context, target.Target, ...make.MakeOption) error // Clean the application Clean(context.Context, target.Target, ...make.MakeOption) error // Delete the build folder of the application Properclean(context.Context, target.Target, ...make.MakeOption) error // Fetch component sources for the applications Fetch(context.Context, target.Target, ...make.MakeOption) error // Set a configuration option for a specific target Set(context.Context, target.Target, ...make.MakeOption) error // Unset a configuration option for a specific target Unset(context.Context, target.Target, ...make.MakeOption) error // Build offers an invocation of the Unikraft build system with the contextual // information of the application Build(context.Context, target.Target, ...BuildOption) error // LibraryNames return names for all libraries in this Compose config LibraryNames() []string // TargetNames return names for all targets in this Compose config TargetNames() []string // Components returns a unique list of Unikraft components which this // applicatiton consists of Components(context.Context, ...target.Target) ([]component.Component, error) // WithTarget is a reducer that returns the application with only the provided // target. WithTarget(target.Target) (Application, error) // Serialize and save the application to the kraftfile Save(context.Context) error // Volumes to be used during runtime of an application. Volumes() []*volume.VolumeConfig // Env variables to be used during building and runtime of application. Env() map[string]string // Removes library from the project directory RemoveLibrary(ctx context.Context, libraryName string) error // Add library to the application. AddLibrary(context.Context, lib.LibraryConfig) error }
func NewApplicationFromInterface ¶ added in v0.3.0
func NewApplicationFromInterface(ctx context.Context, iface map[string]interface{}, popts *ProjectOptions) (Application, error)
func NewApplicationFromKernel ¶ added in v0.7.1
func NewApplicationFromKernel(ctx context.Context, elfPath, configFile, kraftFile string) (Application, error)
This function attempts to read the uk_libinfo section of an ELF binary and fill in the fields of an application on a best-effort basis.
func NewApplicationFromOptions ¶ added in v0.2.0
func NewApplicationFromOptions(aopts ...ApplicationOption) (Application, error)
NewApplicationFromOptions accepts a series of options and returns a rendered *ApplicationConfig structure
func NewProjectFromOptions ¶ added in v0.3.0
func NewProjectFromOptions(ctx context.Context, opts ...ProjectOption) (Application, error)
NewProjectFromOptions load a kraft project based on command line options
type ApplicationOption ¶ added in v0.2.0
type ApplicationOption func(ao *application) error
ApplicationOption is a function that manipulates the instantiation of an Application.
func WithCommand ¶ added in v0.7.0
func WithCommand(command ...string) ApplicationOption
WithCommand sets the command-line arguments for the application.
func WithConfiguration ¶ added in v0.2.0
func WithConfiguration(config ...*kconfig.KeyValue) ApplicationOption
WithConfiguration sets the application's kconfig list
func WithEnv ¶ added in v0.8.3
func WithEnv(env map[string]string) ApplicationOption
WithEnv sets the list of environment variables.
func WithExtensions ¶ added in v0.2.0
func WithExtensions(extensions component.Extensions) ApplicationOption
WithExtensions sets the application's extension list
func WithFilename ¶ added in v0.2.0
func WithFilename(filename string) ApplicationOption
WithFilename sets the application's file name
func WithKraftfile ¶ added in v0.6.4
func WithKraftfile(kraftfile *Kraftfile) ApplicationOption
WithKraftfile sets the application's kraft yaml file
func WithLibraries ¶ added in v0.2.0
func WithLibraries(libraries map[string]*lib.LibraryConfig) ApplicationOption
WithLibraries sets the application's library list
func WithName ¶ added in v0.2.0
func WithName(name string) ApplicationOption
WithName sets the application component name
func WithOutDir ¶ added in v0.2.0
func WithOutDir(outDir string) ApplicationOption
WithOutDir sets the application's output directory
func WithRootfs ¶ added in v0.7.0
func WithRootfs(rootfs string) ApplicationOption
WithRootfs sets the application's rootfs
func WithRuntime ¶ added in v0.7.0
func WithRuntime(rt *runtime.Runtime) ApplicationOption
WithRuntime sets the application's runtime
func WithSource ¶ added in v0.4.0
func WithSource(source string) ApplicationOption
WithSource sets the library's source which indicates where it was retrieved and in component context and not the origin.
func WithTargets ¶ added in v0.2.0
func WithTargets(targets ...target.Target) ApplicationOption
WithTargets sets the application's target list
func WithTemplate ¶ added in v0.2.0
func WithTemplate(template *template.TemplateConfig) ApplicationOption
WithTemplate sets the application's template
func WithUnikraft ¶ added in v0.2.0
func WithUnikraft(unikraft *core.UnikraftConfig) ApplicationOption
WithUnikraft sets the application's core
func WithVersion ¶ added in v0.4.0
func WithVersion(version string) ApplicationOption
WithVersion sets the application version
func WithVolumes ¶ added in v0.7.0
func WithVolumes(volumes ...*volume.VolumeConfig) ApplicationOption
WithVolumes sets the list of volumes to be supplied to the unikernel
func WithWorkingDir ¶ added in v0.2.0
func WithWorkingDir(workingDir string) ApplicationOption
WithWorkingDir sets the application's working directory
type BuildOption ¶
type BuildOption func(opts *BuildOptions) error
func WithBuildLogFile ¶
func WithBuildLogFile(path string) BuildOption
WithBuildLogFile specifies a path to a file which will be used to save the output from Unikraft's build invocation
func WithBuildMakeOptions ¶
func WithBuildMakeOptions(mopts ...make.MakeOption) BuildOption
WithBuildMakeOptions allows customization of the invocation of the GNU make tool
func WithBuildNoPrepare ¶
func WithBuildNoPrepare(noPrepare bool) BuildOption
WithBuildNoPrepare disables calling `make prepare` befere invoking the main Unikraft's build invocation.
func WithBuildProgressFunc ¶
func WithBuildProgressFunc(onProgress func(progress float64)) BuildOption
WithBuildProgressFunc sets an optional progress function which is used as a callback during the ultimate invocation of make within Unikraft's build system
type BuildOptions ¶
type BuildOptions struct {
// contains filtered or unexported fields
}
type ComponentInfoRecord ¶ added in v0.7.1
type ComponentInfoRecord struct { LibName string `yaml:"name,omitempty" json:"name,omitempty"` Comment string `yaml:"comment,omitempty" json:"comment,omitempty"` Version string `yaml:"version,omitempty" json:"version,omitempty"` License string `yaml:"license,omitempty" json:"license,omitempty"` GitDesc string `yaml:"git_description,omitempty" json:"git_description,omitempty"` UkVersion string `yaml:"uk_version,omitempty" json:"uk_version,omitempty"` UkFullVersion string `yaml:"uk_full_version,omitempty" json:"uk_full_version,omitempty"` UkCodeName string `yaml:"uk_code_name,omitempty" json:"uk_code_name,omitempty"` UkConfig []byte `yaml:"uk_config,omitempty" json:"uk_config,omitempty"` UkConfiggz []byte `yaml:"-" json:"-"` Compiler string `yaml:"compiler,omitempty" json:"compiler,omitempty"` CompileDate string `yaml:"compile_date,omitempty" json:"compile_date,omitempty"` CompiledBy string `yaml:"compiled_by,omitempty" json:"compiled_by,omitempty"` CompiledByAssoc string `yaml:"compiled_by_association,omitempty" json:"compiled_by_association,omitempty"` CompileFlags []string `yaml:"compile_flags,omitempty" json:"compile_flags,omitempty"` }
This type contains informations about how the components of a unikernel were built. Those can be either the core(unikraft) or the libraries, the difference being that in the case of the core, the name of the component is empty.
type Kraftfile ¶ added in v0.6.4
type Kraftfile struct {
// contains filtered or unexported fields
}
kraftfile is a filename and the contents of the file
type ProjectOption ¶ added in v0.3.0
type ProjectOption func(*ProjectOptions) error
func WithProjectConfig ¶ added in v0.3.0
func WithProjectConfig(config []string) ProjectOption
WithProjectConfig defines a key=value set of variables used for kraft file interpolation as well as with Unikraft's build system
func WithProjectDefaultKraftfiles ¶ added in v0.3.0
func WithProjectDefaultKraftfiles() ProjectOption
WithProjectDefaultKraftfiles searches for default kraft files from working directory
func WithProjectInterpolation ¶ added in v0.3.0
func WithProjectInterpolation(interpolation bool) ProjectOption
WithProjectInterpolation set ProjectOptions to enable/skip interpolation
func WithProjectKraftfile ¶ added in v0.3.0
func WithProjectKraftfile(file string) ProjectOption
WithProjectKraftfile adds a kraft file to the project
func WithProjectKraftfileFromBytes ¶ added in v0.6.5
func WithProjectKraftfileFromBytes(content []byte) ProjectOption
WithProjectKraftfile adds a kraft file to the project
func WithProjectName ¶ added in v0.3.0
func WithProjectName(name string) ProjectOption
WithProjectName defines ProjectOptions' name
func WithProjectNormalization ¶ added in v0.3.0
func WithProjectNormalization(normalization bool) ProjectOption
WithProjectNormalization set ProjectOptions to enable/skip normalization
func WithProjectResolvedPaths ¶ added in v0.3.0
func WithProjectResolvedPaths(resolve bool) ProjectOption
WithProjectResolvedPaths set ProjectOptions to enable paths resolution
func WithProjectSkipValidation ¶ added in v0.3.0
func WithProjectSkipValidation(skipValidation bool) ProjectOption
WithSkipValidation sets the LoaderOptions to skip validation when loading sections
func WithProjectWorkdir ¶ added in v0.3.0
func WithProjectWorkdir(workdir string) ProjectOption
WithProjectWorkdir defines ProjectOptions' working directory
type ProjectOptions ¶ added in v0.2.0
type ProjectOptions struct {
// contains filtered or unexported fields
}
ProjectOptions group configuration options used to instantiate a new ApplicationConfig from a working directory and a kraftfile
func NewProjectOptions ¶ added in v0.2.0
func NewProjectOptions(opts ...ProjectOption) (*ProjectOptions, error)
NewProjectOptions creates ProjectOptions
func (*ProjectOptions) AddKraftfile ¶ added in v0.3.0
func (popts *ProjectOptions) AddKraftfile(file string) error
AddKraftfile adds and extracts the file contents and attaches it to the ProjectOptions.
func (*ProjectOptions) AddKraftfileFromBytes ¶ added in v0.6.5
func (popts *ProjectOptions) AddKraftfileFromBytes(content []byte) error
AddKraftfileFromBytes adds and extracts the file contents from a given byte slice and attaches it to the ProjectOptions.
func (*ProjectOptions) GetProjectName ¶ added in v0.3.0
func (popts *ProjectOptions) GetProjectName() (string, bool)
GetProjectName returns the project name and whether the project name was set impartively (i.e. by the working directory's name)
func (*ProjectOptions) LookupConfig ¶ added in v0.3.0
func (popts *ProjectOptions) LookupConfig(key string) (string, bool)
LookupConfig provides a lookup function for config variables
func (*ProjectOptions) RelativePath ¶ added in v0.3.0
func (popts *ProjectOptions) RelativePath(path string) string
RelativePath resolve a relative path based project's working directory
func (*ProjectOptions) SetProjectName ¶ added in v0.3.0
func (popts *ProjectOptions) SetProjectName(name string, imperativelySet bool)
SetProjectName sets the project name along with whether the name is set imperatively (i.e. whether it was derived from the working directory)
func (*ProjectOptions) Workdir ¶ added in v0.3.0
func (popts *ProjectOptions) Workdir() (string, error)
Workdir returns the working directory determined by provided kraft files
type Transformer ¶ added in v0.2.0
type Transformer struct { TypeOf reflect.Type Func TransformerFunc }
Transformer defines a map to type transformer
type TransformerFunc ¶ added in v0.2.0
TransformerFunc defines a function to perform the actual transformation