app

package
v0.2.1-2-g5dc37d7 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2022 License: BSD-3-Clause Imports: 35 Imported by: 3

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

View Source
const (
	DefaultOutputDir  = "build"
	DefaultConfigFile = ".config"
)

Variables

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

func IsWorkdirInitialized(dir string) bool

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

func ParseYAML(source []byte) (map[string]interface{}, error)

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 Application interface {
	component.Component
}

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

Build offers an invocation of the Unikraft build system with the contextual information of the ApplicationConfigs

func (*ApplicationConfig) Clean

Clean the application

func (ApplicationConfig) Component

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

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

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 (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

Template returns the application's template

func (ApplicationConfig) Type

func (ApplicationConfig) Unikraft

func (ac ApplicationConfig) Unikraft() (core.UnikraftConfig, error)

Unikraft returns the application's unikraft configuration

func (*ApplicationConfig) Unset

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

Jump to

Keyboard shortcuts

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