schema

package
v0.1.1-2-ga0ebd91 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2022 License: BSD-3-Clause Imports: 31 Imported by: 0

Documentation

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)

View Source
var Schema string

Schema is the kraft-spec JSON schema

Functions

func IsWorkdirInitialized

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 Load

func Load(details config.ConfigDetails, options ...func(*LoaderOptions)) (*app.ApplicationConfig, error)

Load reads a ConfigDetails and returns a fully loaded configuration

func LoadLibraries

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

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 LoadUnikraft

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 NewApplicationFromOptions

func NewApplicationFromOptions(popts *ProjectOptions, copts ...component.ComponentOption) (*app.ApplicationConfig, error)

NewApplicationFromOptions load a kraft project based on command line options

func ParseYAML

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

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 Validate

func Validate(config map[string]interface{}) error

Validate uses the jsonschema to validate the configuration

func WithSkipValidation

func WithSkipValidation(opts *LoaderOptions)

WithSkipValidation sets the LoaderOptions to skip validation when loading sections

Types

type LoaderOptions

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
	// PackageManager can be injected to each component to allow easy retrieval of
	// the component itself with regard to its source files as well as Unikraft's
	PackageManager *packmanager.PackageManager
	// contains filtered or unexported fields
}

LoaderOptions supported by Load

func (LoaderOptions) GetProjectName

func (o LoaderOptions) GetProjectName() (string, bool)

func (*LoaderOptions) SetProjectName

func (o *LoaderOptions) SetProjectName(name string, imperativelySet bool)

type ProjectOptions

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

func NewProjectOptions(configs []string, opts ...ProjectOptionsFn) (*ProjectOptions, error)

NewProjectOptions creates ProjectOptions

func (ProjectOptions) GetWorkingDir

func (o ProjectOptions) GetWorkingDir() (string, error)

type ProjectOptionsFn

type ProjectOptionsFn func(*ProjectOptions) error

func WithConfig

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

func WithConfigFile(file string) ProjectOptionsFn

WithConfigFile set an alternate config file

func WithDefaultConfigPath

func WithDefaultConfigPath() ProjectOptionsFn

WithDefaultConfigPath searches for default config files from working directory

func WithDotConfig

func WithDotConfig(enforce bool) ProjectOptionsFn

WithDotConfig imports configuration variables from .config file

func WithInterpolation

func WithInterpolation(interpolation bool) ProjectOptionsFn

WithInterpolation set ProjectOptions to enable/skip interpolation

func WithLogger

func WithLogger(l log.Logger) ProjectOptionsFn

WithLogger defines the log.Logger

func WithName

func WithName(name string) ProjectOptionsFn

WithName defines ProjectOptions' name

func WithNormalization

func WithNormalization(normalization bool) ProjectOptionsFn

WithNormalization set ProjectOptions to enable/skip normalization

func WithPackageManager

func WithPackageManager(pm *packmanager.PackageManager) ProjectOptionsFn

WithPackageManager provides access to the package manager of choice to be able to retrieve component sources

func WithResolvedPaths

func WithResolvedPaths(resolve bool) ProjectOptionsFn

WithResolvedPaths set ProjectOptions to enable paths resolution

func WithWorkingDirectory

func WithWorkingDirectory(wd string) ProjectOptionsFn

WithWorkingDirectory defines ProjectOptions' working directory

type Transformer

type Transformer struct {
	TypeOf reflect.Type
	Func   TransformerFunc
}

Transformer defines a map to type transformer

type TransformerFunc

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