app

package
v0.3.0-21-gf283c75 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2023 License: BSD-3-Clause Imports: 33 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.

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

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{}, popts *ProjectOptions) (map[string]lib.LibraryConfig, error)

LoadLibraries produces a LibraryConfig map from a kraft file Dict the source Dict is not validated if directly used.

func LoadTargets added in v0.2.0

func LoadTargets(source []interface{}, popts *ProjectOptions) ([]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{}, popts *ProjectOptions) (kraftTemplate.TemplateConfig, error)

LoadTemplate produces a TemplateConfig from a kraft file Dict the source Dict is not validated if directly used.

func LoadUnikraft added in v0.2.0

func LoadUnikraft(source interface{}, popts *ProjectOptions) (core.UnikraftConfig, error)

LoadUnikraft produces a UnikraftConfig from a kraft file Dict the source Dict is not validated if directly used.

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.

Types

type Application

type Application interface {
	component.Component
}

type ApplicationConfig

type ApplicationConfig struct {
	component.ComponentConfig
	// contains filtered or unexported fields
}

func MergeApplicationConfigs added in v0.3.0

func MergeApplicationConfigs(apps []*ApplicationConfig) (*ApplicationConfig, error)

func NewApplicationFromInterface added in v0.3.0

func NewApplicationFromInterface(iface map[string]interface{}, popts *ProjectOptions) (*ApplicationConfig, error)

func NewApplicationFromOptions added in v0.2.0

func NewApplicationFromOptions(aopts ...ApplicationOption) (*ApplicationConfig, error)

NewApplicationFromOptions accepts a series of options and returns a rendered *ApplicationConfig structure

func NewProjectFromOptions added in v0.3.0

func NewProjectFromOptions(opts ...ProjectOption) (*ApplicationConfig, error)

NewProjectFromOptions load a kraft project based on command line options

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 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 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 ProjectOption added in v0.3.0

type ProjectOption func(*ProjectOptions) error

func WithProjectComponentOptions added in v0.3.0

func WithProjectComponentOptions(copts ...component.ComponentOption) ProjectOption

WithProjectComponentOptions adds the set of options to apply to each component during their instantiation

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 WithProjectDotConfig added in v0.3.0

func WithProjectDotConfig(enforce bool) ProjectOption

WithProjectDotConfig imports configuration variables from .config file

func WithProjectDotConfigFile added in v0.3.0

func WithProjectDotConfigFile(file string) ProjectOption

WithProjectDotConfigFile set an alternate config file

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 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 set of kraftfiles

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

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