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 expect in compliance with the License.
Index ¶
- Constants
- Variables
- func IsWorkdirInitialized(dir string) bool
- func LoadLibraries(source map[string]interface{}, opts *LoaderOptions) (map[string]lib.LibraryConfig, error)
- func LoadTargets(source []interface{}, configDetails config.ConfigDetails, outdir string, ...) ([]target.TargetConfig, error)
- func LoadTemplate(source interface{}, opts *LoaderOptions) (kraftTemplate.TemplateConfig, error)
- func LoadUnikraft(source interface{}, opts *LoaderOptions) (core.UnikraftConfig, error)
- func ParseYAML(source []byte) (map[string]interface{}, error)
- func Transform(source interface{}, target interface{}, additionalTransformers ...Transformer) error
- func WithSkipValidation(opts *LoaderOptions)
- type Application
- type ApplicationConfig
- func Load(details config.ConfigDetails, options ...func(*LoaderOptions)) (*ApplicationConfig, error)
- func NewApplicationFromOptions(popts *ProjectOptions, copts ...component.ComponentOption) (*ApplicationConfig, error)
- func NewApplicationOptions(aopts ...ApplicationOption) (*ApplicationConfig, error)
- func (a *ApplicationConfig) Build(ctx context.Context, tc *target.TargetConfig, opts ...BuildOption) error
- func (a *ApplicationConfig) Clean(ctx context.Context, tc *target.TargetConfig, mopts ...make.MakeOption) error
- func (ac ApplicationConfig) Component() component.ComponentConfig
- func (ac *ApplicationConfig) Components() ([]component.Component, error)
- func (ac ApplicationConfig) Configuration() (kconfig.KConfigValues, error)
- func (a *ApplicationConfig) Configure(ctx context.Context, tc *target.TargetConfig, mopts ...make.MakeOption) error
- func (ac *ApplicationConfig) DefConfig(ctx context.Context, tc *target.TargetConfig, extra *kconfig.KConfigValues, ...) error
- func (ac ApplicationConfig) Extensions() (component.Extensions, error)
- func (a *ApplicationConfig) Fetch(ctx context.Context, tc *target.TargetConfig, mopts ...make.MakeOption) error
- func (ac ApplicationConfig) Filename() string
- func (ac *ApplicationConfig) IsConfigured(tc *target.TargetConfig) bool
- func (ac *ApplicationConfig) KConfigFile(tc *target.TargetConfig) string
- func (ac ApplicationConfig) KConfigMenu() (*kconfig.KConfigFile, error)
- func (ac ApplicationConfig) KConfigValues() (kconfig.KConfigValues, error)
- func (ac ApplicationConfig) KraftFiles() ([]string, error)
- func (ac ApplicationConfig) Libraries() (lib.Libraries, error)
- func (a *ApplicationConfig) LibraryNames() []string
- func (a *ApplicationConfig) Make(ctx context.Context, tc *target.TargetConfig, mopts ...make.MakeOption) error
- func (a *ApplicationConfig) MakeArgs(tc *target.TargetConfig) (*core.MakeArgs, error)
- func (ac *ApplicationConfig) MergeTemplate(app *ApplicationConfig) *ApplicationConfig
- func (ac ApplicationConfig) Name() string
- func (ac ApplicationConfig) OutDir() string
- func (a *ApplicationConfig) Prepare(ctx context.Context, tc *target.TargetConfig, mopts ...make.MakeOption) error
- func (ac ApplicationConfig) PrintInfo() string
- func (a *ApplicationConfig) Properclean(ctx context.Context, tc *target.TargetConfig, mopts ...make.MakeOption) error
- func (a *ApplicationConfig) Set(ctx context.Context, tc *target.TargetConfig, mopts ...make.MakeOption) error
- func (ac ApplicationConfig) Source() string
- func (a *ApplicationConfig) SyncConfig(ctx context.Context, tc *target.TargetConfig, mopts ...make.MakeOption) error
- func (a *ApplicationConfig) TargetByName(name string) (*target.TargetConfig, error)
- func (a *ApplicationConfig) TargetNames() []string
- func (ac ApplicationConfig) Targets() (target.Targets, error)
- func (ac ApplicationConfig) Template() template.TemplateConfig
- func (ac ApplicationConfig) Type() unikraft.ComponentType
- func (ac ApplicationConfig) Unikraft() (core.UnikraftConfig, error)
- func (a *ApplicationConfig) Unset(ctx context.Context, tc *target.TargetConfig, mopts ...make.MakeOption) error
- func (ac ApplicationConfig) Version() string
- func (ac ApplicationConfig) WorkingDir() string
- type ApplicationOption
- func WithConfiguration(configuration kconfig.KConfigValues) ApplicationOption
- func WithExtensions(extensions component.Extensions) ApplicationOption
- func WithFilename(filename string) ApplicationOption
- func WithKraftFiles(kraftFiles []string) ApplicationOption
- func WithLibraries(libraries lib.Libraries) ApplicationOption
- func WithOutDir(outDir string) ApplicationOption
- func WithTargets(targets target.Targets) ApplicationOption
- func WithTemplate(template template.TemplateConfig) ApplicationOption
- func WithUnikraft(unikraft core.UnikraftConfig) ApplicationOption
- func WithWorkingDir(workingDir string) ApplicationOption
- type BuildOption
- type BuildOptions
- type LoaderOptions
- type ProjectOptions
- type ProjectOptionsFn
- func WithConfig(config []string) ProjectOptionsFn
- func WithConfigFile(file string) ProjectOptionsFn
- func WithDefaultConfigPath() ProjectOptionsFn
- func WithDotConfig(enforce bool) ProjectOptionsFn
- func WithInterpolation(interpolation bool) ProjectOptionsFn
- func WithName(name string) ProjectOptionsFn
- func WithNormalization(normalization bool) ProjectOptionsFn
- func WithResolvedPaths(resolve bool) ProjectOptionsFn
- func WithWorkingDirectory(wd string) ProjectOptionsFn
- type Transformer
- type TransformerFunc
Constants ¶
const ( DefaultOutputDir = "build" 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)
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.
func LoadLibraries ¶ added in v0.2.0
func LoadLibraries(source map[string]interface{}, opts *LoaderOptions) (map[string]lib.LibraryConfig, error)
LoadLibraries produces a LibraryConfig map from a kraft file Dict the source Dict is not validated if directly used. Use Load() to enable validation
func LoadTargets ¶ added in v0.2.0
func LoadTargets(source []interface{}, configDetails config.ConfigDetails, outdir string, opts *LoaderOptions) ([]target.TargetConfig, error)
LoadTargets produces a LibraryConfig map from a kraft file Dict the source Dict is not validated if directly used. Use Load() to enable validation
func LoadTemplate ¶ added in v0.2.0
func LoadTemplate(source interface{}, opts *LoaderOptions) (kraftTemplate.TemplateConfig, error)
LoadTemplate produces a TemplateConfig from a kraft file Dict the source Dict is not validated if directly used. Use Load() to enable validation
func LoadUnikraft ¶ added in v0.2.0
func LoadUnikraft(source interface{}, opts *LoaderOptions) (core.UnikraftConfig, error)
LoadUnikraft produces a UnikraftConfig from a kraft file Dict the source Dict is not validated if directly used. Use Load() to enable validation
func ParseYAML ¶ added in v0.2.0
ParseYAML reads the bytes from a file, parses the bytes into a mapping structure, and returns it.
func Transform ¶ added in v0.2.0
func Transform(source interface{}, target interface{}, additionalTransformers ...Transformer) error
Transform converts the source into the target struct with compose types transformer and the specified transformers if any.
func WithSkipValidation ¶ added in v0.2.0
func WithSkipValidation(opts *LoaderOptions)
WithSkipValidation sets the LoaderOptions to skip validation when loading sections
Types ¶
type Application ¶
type ApplicationConfig ¶
type ApplicationConfig struct { component.ComponentConfig // contains filtered or unexported fields }
func Load ¶ added in v0.2.0
func Load(details config.ConfigDetails, options ...func(*LoaderOptions)) (*ApplicationConfig, error)
Load reads a ConfigDetails and returns a fully loaded configuration
func NewApplicationFromOptions ¶ added in v0.2.0
func NewApplicationFromOptions(popts *ProjectOptions, copts ...component.ComponentOption) (*ApplicationConfig, error)
NewApplicationFromOptions load a kraft project based on command line options
func NewApplicationOptions ¶ added in v0.2.0
func NewApplicationOptions(aopts ...ApplicationOption) (*ApplicationConfig, error)
NewApplicationOptions accepts a series of options and returns a rendered *ApplicationOptions structure
func (*ApplicationConfig) Build ¶
func (a *ApplicationConfig) Build(ctx context.Context, tc *target.TargetConfig, opts ...BuildOption) error
Build offers an invocation of the Unikraft build system with the contextual information of the ApplicationConfigs
func (*ApplicationConfig) Clean ¶
func (a *ApplicationConfig) Clean(ctx context.Context, tc *target.TargetConfig, mopts ...make.MakeOption) error
Clean the application
func (ApplicationConfig) Component ¶
func (ac ApplicationConfig) Component() component.ComponentConfig
func (*ApplicationConfig) Components ¶
func (ac *ApplicationConfig) Components() ([]component.Component, error)
Components returns a unique list of Unikraft components which this applicatiton consists of
func (ApplicationConfig) Configuration ¶
func (ac ApplicationConfig) Configuration() (kconfig.KConfigValues, error)
Configuration returns the application's kconfig list
func (*ApplicationConfig) Configure ¶
func (a *ApplicationConfig) Configure(ctx context.Context, tc *target.TargetConfig, mopts ...make.MakeOption) error
Configure the application
func (*ApplicationConfig) DefConfig ¶
func (ac *ApplicationConfig) DefConfig(ctx context.Context, tc *target.TargetConfig, extra *kconfig.KConfigValues, mopts ...make.MakeOption) error
Defconfig updates the configuration
func (ApplicationConfig) Extensions ¶
func (ac ApplicationConfig) Extensions() (component.Extensions, error)
Extensions returns the application's extensions
func (*ApplicationConfig) Fetch ¶
func (a *ApplicationConfig) Fetch(ctx context.Context, tc *target.TargetConfig, mopts ...make.MakeOption) error
Fetch component sources for the applications
func (ApplicationConfig) Filename ¶
func (ac ApplicationConfig) Filename() string
Filename returns the path to the application's executable
func (*ApplicationConfig) IsConfigured ¶
func (ac *ApplicationConfig) IsConfigured(tc *target.TargetConfig) bool
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
func (*ApplicationConfig) KConfigFile ¶
func (ac *ApplicationConfig) KConfigFile(tc *target.TargetConfig) string
KConfigFile returns the path to the application's .config file or the target-specific `.config` file which is formatted `.config.<TARGET-NAME>`
func (ApplicationConfig) KConfigMenu ¶
func (ac ApplicationConfig) KConfigMenu() (*kconfig.KConfigFile, error)
func (ApplicationConfig) KConfigValues ¶
func (ac ApplicationConfig) KConfigValues() (kconfig.KConfigValues, error)
func (ApplicationConfig) KraftFiles ¶
func (ac ApplicationConfig) KraftFiles() ([]string, error)
KraftFiles returns the application's kraft configuration files
func (ApplicationConfig) Libraries ¶
func (ac ApplicationConfig) Libraries() (lib.Libraries, error)
Libraries returns the application libraries' configurations
func (*ApplicationConfig) LibraryNames ¶
func (a *ApplicationConfig) LibraryNames() []string
LibraryNames return names for all libraries in this Compose config
func (*ApplicationConfig) Make ¶
func (a *ApplicationConfig) Make(ctx context.Context, tc *target.TargetConfig, mopts ...make.MakeOption) 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.
func (*ApplicationConfig) MakeArgs ¶
func (a *ApplicationConfig) MakeArgs(tc *target.TargetConfig) (*core.MakeArgs, error)
MakeArgs returns the populated `core.MakeArgs` based on the contents of the instantiated `ApplicationConfig`. This information can be passed directly to Unikraft's build system.
func (*ApplicationConfig) MergeTemplate ¶ added in v0.2.0
func (ac *ApplicationConfig) MergeTemplate(app *ApplicationConfig) *ApplicationConfig
MergeTemplate merges the application's configuration with the given configuration
func (ApplicationConfig) Name ¶
func (ac ApplicationConfig) Name() string
func (ApplicationConfig) OutDir ¶
func (ac ApplicationConfig) OutDir() string
OutDir returns the path to the application's output directory
func (*ApplicationConfig) Prepare ¶
func (a *ApplicationConfig) Prepare(ctx context.Context, tc *target.TargetConfig, mopts ...make.MakeOption) error
Prepare the application
func (ApplicationConfig) PrintInfo ¶
func (ac ApplicationConfig) PrintInfo() string
func (*ApplicationConfig) Properclean ¶
func (a *ApplicationConfig) Properclean(ctx context.Context, tc *target.TargetConfig, mopts ...make.MakeOption) error
Delete the build folder of the application
func (*ApplicationConfig) Set ¶
func (a *ApplicationConfig) Set(ctx context.Context, tc *target.TargetConfig, mopts ...make.MakeOption) error
func (ApplicationConfig) Source ¶
func (ac ApplicationConfig) Source() string
func (*ApplicationConfig) SyncConfig ¶
func (a *ApplicationConfig) SyncConfig(ctx context.Context, tc *target.TargetConfig, mopts ...make.MakeOption) error
SyncConfig updates the configuration
func (*ApplicationConfig) TargetByName ¶
func (a *ApplicationConfig) TargetByName(name string) (*target.TargetConfig, error)
TargetByName returns the `*target.TargetConfig` based on an input name
func (*ApplicationConfig) TargetNames ¶
func (a *ApplicationConfig) TargetNames() []string
TargetNames return names for all targets in this Compose config
func (ApplicationConfig) Targets ¶
func (ac ApplicationConfig) Targets() (target.Targets, error)
Targets returns the application's targets
func (ApplicationConfig) Template ¶ added in v0.2.0
func (ac ApplicationConfig) Template() template.TemplateConfig
Template returns the application's template
func (ApplicationConfig) Type ¶
func (ac ApplicationConfig) Type() unikraft.ComponentType
func (ApplicationConfig) Unikraft ¶
func (ac ApplicationConfig) Unikraft() (core.UnikraftConfig, error)
Unikraft returns the application's unikraft configuration
func (*ApplicationConfig) Unset ¶
func (a *ApplicationConfig) Unset(ctx context.Context, tc *target.TargetConfig, mopts ...make.MakeOption) error
func (ApplicationConfig) Version ¶
func (ac ApplicationConfig) Version() string
func (ApplicationConfig) WorkingDir ¶
func (ac ApplicationConfig) WorkingDir() string
WorkingDir returns the path to the application's working directory
type ApplicationOption ¶ added in v0.2.0
type ApplicationOption func(ao *ApplicationConfig) error
ApplicationOption is a function that operates on an ApplicationConfig
func WithConfiguration ¶ added in v0.2.0
func WithConfiguration(configuration kconfig.KConfigValues) ApplicationOption
WithConfiguration sets the application's kconfig list
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 WithKraftFiles ¶ added in v0.2.0
func WithKraftFiles(kraftFiles []string) ApplicationOption
WithKraftFiles sets the application's kraft yaml files
func WithLibraries ¶ added in v0.2.0
func WithLibraries(libraries lib.Libraries) ApplicationOption
WithLibraries sets the application's library list
func WithOutDir ¶ added in v0.2.0
func WithOutDir(outDir string) ApplicationOption
WithOutDir sets the application's output directory
func WithTargets ¶ added in v0.2.0
func WithTargets(targets target.Targets) 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 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 LoaderOptions ¶ added in v0.2.0
type LoaderOptions struct { // Skip schema validation SkipValidation bool // Skip interpolation SkipInterpolation bool // Skip normalization SkipNormalization bool // Resolve paths ResolvePaths bool // Interpolation options Interpolate *interp.Options // contains filtered or unexported fields }
LoaderOptions supported by Load
func (LoaderOptions) GetProjectName ¶ added in v0.2.0
func (o LoaderOptions) GetProjectName() (string, bool)
func (*LoaderOptions) SetProjectName ¶ added in v0.2.0
func (o *LoaderOptions) SetProjectName(name string, imperativelySet bool)
type ProjectOptions ¶ added in v0.2.0
type ProjectOptions struct { Name string WorkingDir string ConfigPaths []string Configuration kconfig.KConfigValues DotConfigFile string // contains filtered or unexported fields }
ProjectOptions groups the command line options recommended for a Compose implementation
func NewProjectOptions ¶ added in v0.2.0
func NewProjectOptions(configs []string, opts ...ProjectOptionsFn) (*ProjectOptions, error)
NewProjectOptions creates ProjectOptions
func (ProjectOptions) GetWorkingDir ¶ added in v0.2.0
func (o ProjectOptions) GetWorkingDir() (string, error)
type ProjectOptionsFn ¶ added in v0.2.0
type ProjectOptionsFn func(*ProjectOptions) error
func WithConfig ¶ added in v0.2.0
func WithConfig(config []string) ProjectOptionsFn
WithConfig defines a key=value set of variables used for kraft file interpolation as well as with Unikraft's build system
func WithConfigFile ¶ added in v0.2.0
func WithConfigFile(file string) ProjectOptionsFn
WithConfigFile set an alternate config file
func WithDefaultConfigPath ¶ added in v0.2.0
func WithDefaultConfigPath() ProjectOptionsFn
WithDefaultConfigPath searches for default config files from working directory
func WithDotConfig ¶ added in v0.2.0
func WithDotConfig(enforce bool) ProjectOptionsFn
WithDotConfig imports configuration variables from .config file
func WithInterpolation ¶ added in v0.2.0
func WithInterpolation(interpolation bool) ProjectOptionsFn
WithInterpolation set ProjectOptions to enable/skip interpolation
func WithName ¶ added in v0.2.0
func WithName(name string) ProjectOptionsFn
WithName defines ProjectOptions' name
func WithNormalization ¶ added in v0.2.0
func WithNormalization(normalization bool) ProjectOptionsFn
WithNormalization set ProjectOptions to enable/skip normalization
func WithResolvedPaths ¶ added in v0.2.0
func WithResolvedPaths(resolve bool) ProjectOptionsFn
WithResolvedPaths set ProjectOptions to enable paths resolution
func WithWorkingDirectory ¶ added in v0.2.0
func WithWorkingDirectory(wd string) ProjectOptionsFn
WithWorkingDirectory defines ProjectOptions' working directory
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
type TransformerFunc func(interface{}) (interface{}, error)
TransformerFunc defines a function to perform the actual transformation