data

package
v0.0.0-...-9da1c94 Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2023 License: AGPL-3.0, AGPL-3.0-or-later Imports: 21 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EvalFile

func EvalFile(inputFile *File, prompt bool, env conf.Configuration, artHome string) error

func EvalSecret

func EvalSecret(inputSecret *Secret, prompt bool, env conf.Configuration) error

func EvalVar

func EvalVar(inputVar *Var, prompt bool, env conf.Configuration) error

func NormInputName

func NormInputName(name string) string

NormInputName ensure the passed in name is formatted as a valid environment variable name

Types

type Access

type Access string
const (
	AccessPublic   Access = "public"
	AccessInternal Access = "internal"
	AccessPrivate  Access = "private"
)

type BuildFile

type BuildFile struct {

	// the URI of the Git repo
	GitURI string `yaml:"git_uri,omitempty"`
	// the runtime to use to run functions
	Runtime string `yaml:"runtime,omitempty"`
	// the environment variables that apply to the build
	// any variables defined at this level will be available to all build profiles
	// in addition, the defined variables are added on top of the existing environment
	Env map[string]string `yaml:"env,omitempty"`
	// a list of labels to be added to the package seal
	// they should be used to document key aspects of the package in a generic way
	Labels map[string]string `yaml:"labels,omitempty"`
	// any input required by functions
	Input *Input `yaml:"input,omitempty"`
	// a list of build configurations in the form of labels, commands to run and environment variables
	Profiles []*Profile `yaml:"profiles,omitempty"`
	// a list of functions containing a list of commands to execute
	Functions []*Function `yaml:"functions"`
	// include other build files
	Includes []interface{}     `yaml:"includes"`
	SKU      string            `yaml:"sku"`
	X        map[string]string `json:"x,omitempty"`
	// contains filtered or unexported fields
}

BuildFile structure of build.yaml file

func LoadBuildFile

func LoadBuildFile(path string) (*BuildFile, error)

func LoadBuildFileWithEnv

func LoadBuildFileWithEnv(path string, ev conf.Configuration, isChild bool) (*BuildFile, error)

func (*BuildFile) DefaultProfile

func (b *BuildFile) DefaultProfile() *Profile

DefaultProfile return the default profile if exists

func (*BuildFile) ExportFxs

func (b *BuildFile) ExportFxs() bool

func (*BuildFile) Fx

func (b *BuildFile) Fx(name string) *Function

Fx return the function in the build file specified by its name

func (*BuildFile) GetEnv

func (b *BuildFile) GetEnv() map[string]string

func (*BuildFile) GetXEnv

func (b *BuildFile) GetXEnv() *merge.Envar

func (*BuildFile) Profile

func (b *BuildFile) Profile(name string) *Profile

Profile return the build profile specified by its name

func (*BuildFile) Validate

func (b *BuildFile) Validate() (bool, error)

type File

type File struct {
	// the unique reference for the file
	Name string `yaml:"name"`
	// a description of the intended use of this file
	Description string `yaml:"description"`
	// path to the file within the Artisan registry
	Path string
	// the file content
	Content string
}

type Files

type Files []*File

type Function

type Function struct {
	// the name of the function
	Name string `yaml:"name"`
	// the description for the function
	Description string `yaml:"description,omitempty"`
	// a set of environment variables required by the run commands
	Env map[string]string `yaml:"env,omitempty"`
	// the commands to be executed by the function
	Run []string `yaml:"run,omitempty"`
	// is this function to be available in the manifest
	Export *bool `yaml:"export,omitempty"`
	// defines any bindings to inputs required to run this function
	Input *InputBinding `yaml:"input,omitempty"`
	// the runtime to run this function
	Runtime string   `yaml:"runtime,omitempty"`
	Credits int      `yaml:"credits,omitempty"`
	Network *Network `json:"network,omitempty"`
}

func (*Function) GetEnv

func (f *Function) GetEnv() map[string]string

GetEnv gets a slice of string with each element containing key=value

func (*Function) Survey

func (f *Function) Survey(env conf.Configuration) conf.Configuration

Survey all missing variables in the function pass in any available environment variables so that they are not surveyed

type FxInfo

type FxInfo struct {
	Name        string   `json:"name"`
	Description string   `json:"description"`
	Input       *Input   `json:"input,omitempty"`
	Credits     int      `json:"credits,omitempty"`
	Runtime     string   `json:"runtime,omitempty"` // runtime image that should be used to execute functions in the package
	Network     *Network `json:"network,omitempty"`
}

FxInfo exported function list

type Group

type Group struct {
	Tags []string `yaml:"tags"`
	IPs  []string `yaml:"ips"`
}

type GroupInfo

type GroupInfo struct {
	Group string
	Tags  []string
	Min   int
	Max   int
	IPs   []string
}

type GroupsInfo

type GroupsInfo []GroupInfo

func (*GroupsInfo) GroupIx

func (gs *GroupsInfo) GroupIx(name string) int

type Input

type Input struct {
	// required by configuration files
	File Files `yaml:"file,omitempty" json:"file,omitempty"`
	// required string value secrets
	Secret Secrets `yaml:"secret,omitempty" json:"secret,omitempty"`
	// required variables
	Var Vars `yaml:"var,omitempty" json:"var,omitempty"`
}

Input describes exported input information required by functions or runtimes

func SurveyInputFromBuildFile

func SurveyInputFromBuildFile(fxName string, buildFile *BuildFile, prompt, defOnly bool, env conf.Configuration, artHome string) (*Input, error)

SurveyInputFromBuildFile extracts the build file Input that is relevant to a function (using its bindings)

func SurveyInputFromManifest

func SurveyInputFromManifest(flowName, stepName, packageSource, domain string, fxName string, manifest *Manifest, prompt, defOnly bool, env conf.Configuration, artHome string) (*Input, error)

SurveyInputFromManifest extracts the package manifest Input in an exported function

func SurveyInputFromURI

func SurveyInputFromURI(uri string, prompt, defOnly bool, env conf.Configuration, artHome string) (*Input, error)

func (*Input) Env

func (i *Input) Env() *merge.Envar

func (*Input) HasSecret

func (i *Input) HasSecret(name string) bool

func (*Input) HasSecretBinding

func (i *Input) HasSecretBinding(binding string) bool

func (*Input) HasVar

func (i *Input) HasVar(name string) bool

func (*Input) HasVarBinding

func (i *Input) HasVarBinding(binding string) bool

func (*Input) Merge

func (i *Input) Merge(in *Input)

Merge the passed in input with the current input

func (*Input) SecretExist

func (i *Input) SecretExist(name string) bool

func (*Input) SurveyRegistryCreds

func (i *Input) SurveyRegistryCreds(flowName, stepName, packageSource, domain string, prompt, defOnly bool, env conf.Configuration) error

func (*Input) ToEnvFile

func (i *Input) ToEnvFile() []byte

func (*Input) VarExist

func (i *Input) VarExist(name string) bool

type InputBinding

type InputBinding struct {
	Var    []string `yaml:"var"`
	Secret []string `yaml:"secret"`
	Key    []string `yaml:"key"`
	File   []string `yaml:"file"`
}

InputBinding list the names of the inputs required by a function

type Manifest

type Manifest struct {
	// the author of the package
	Author string `json:"author,omitempty"`
	// the signing and verification authority for the package
	Authority []string `json:"authority,omitempty"`
	// the package type
	Type string `json:"type,omitempty"`
	// the license associated to the package
	License string `json:"license,omitempty"`
	// the target OS for the package
	OS string `json:"os"`
	// the name of the package file
	Ref string `json:"ref"`
	// the build profile used
	Profile string `json:"profile"`
	// runtime image that should be used to execute exported functions in the package
	Runtime string `json:"runtime,omitempty"`
	// the labels assigned to the package
	Labels map[string]string `json:"labels,omitempty"`
	// the URI of the package source
	Source string `json:"source,omitempty"`
	// the path within the source where the project is (for uber repos)
	SourcePath string `json:"source_path,omitempty"`
	// the commit hash
	Commit string `json:"commit,omitempty"`
	// repo branch
	Branch string `json:"branch,omitempty"`
	// the name of the file or folder that has been packaged
	Target string `json:"target,omitempty"`
	// the timestamp
	Time string `json:"time"`
	// the size of the package
	Size string `json:"size"`
	// the Stock Keeping Unit code
	SKU string `json:"SKU,omitempty"`
	// what functions are available to call?
	Functions  []*FxInfo `json:"functions,omitempty"`
	OpenPolicy string    `json:"open_policy,omitempty"`
	RunPolicy  string    `json:"run_policy,omitempty"`
	SignPolicy string    `json:"sign_policy,omitempty"`
}

func (*Manifest) Fx

func (m *Manifest) Fx(name string) *FxInfo

func (*Manifest) ListFxs

func (m *Manifest) ListFxs(artHome string)

func (*Manifest) ToMarkDownBytes

func (m *Manifest) ToMarkDownBytes(name string) []byte

type Network

type Network struct {
	Groups []string `yaml:"groups"`
	Rules  []string `yaml:"rules"`
}

func (*Network) AllocateIPs

func (n *Network) AllocateIPs(ipList ...string) (GroupsInfo, error)

type Profile

type Profile struct {
	// the name of the profile
	Name string `yaml:"name"`
	// whether this is the default profile
	Default bool `yaml:"default"`
	// the name of the application
	Application string `yaml:"application"`
	// the type of license used by the application
	// if not empty, it is added to the package seal
	License string `yaml:"license"`
	// the type of technology used by the application that can be used to determine the tool chain to use
	// e.g. java, nodejs, golang, python, php, etc
	Type string `yaml:"type"`
	// the pipeline Icon
	Icon string `yaml:"icon"`
	// a set of labels associated with the profile
	Labels map[string]string `yaml:"labels"`
	// a set of environment variables required by the run commands
	Env map[string]string `yaml:"env"`
	// the commands to be executed to build the application
	Run []string `yaml:"run"`
	// the output of the build process, namely either a file or a folder, that has to be compressed
	// as part of the packaging process
	Target string `yaml:"target"`
	// merged target if existed, internal use only
	MergedTarget string
}

func (*Profile) GetEnv

func (p *Profile) GetEnv() map[string]string

GetEnv gets a slice of string with each element containing key=value

func (*Profile) Survey

func (p *Profile) Survey(bf *BuildFile) conf.Configuration

Survey all missing variables in the profile

type Role

type Role struct {
	Name string `yaml:"name"`
	Min  int    `yaml:"min,omitempty"`
	Max  int    `yaml:"max,omitempty"`
	Tag  []Tag  `yaml:"tag,omitempty"`
}

type RunHandler

type RunHandler func(name *core.PackageName, fx string, seal *Seal) error

type Seal

type Seal struct {
	// the package metadata
	Manifest *Manifest `json:"manifest"`
	// the combined checksum of the package and its metadata
	Digest string `json:"digest"`
	// the map of digital seals for this package
	Seal map[string]string `json:"seal,omitempty"`
}

Seal the digital Seal for a package the Seal contains information to determine if the package or its metadata has been compromised and therefore the Seal is broken

func (*Seal) DSha256

func (seal *Seal) DSha256(path string) (string, error)

DSha256 calculates the package SHA-256 digest by taking the combined checksum of the Seal information and the compressed file

func (*Seal) NoAuthority

func (seal *Seal) NoAuthority() bool

NoAuthority returns true if the seal does not have an authority

func (*Seal) PackageId

func (seal *Seal) PackageId() (string, error)

PackageId the package id calculated as the hex encoded SHA-256 digest of the artefact Seal

func (*Seal) SealFile

func (seal *Seal) SealFile(registryRoot string) string

func (*Seal) Valid

func (seal *Seal) Valid(path string) (valid bool, err error)

Valid checks that the digest stored in the seal is the same as the digest generated using the passed-in zip file path and the seal path: the path to the package zip file to validate

func (*Seal) ZipFile

func (seal *Seal) ZipFile(registryRoot string) string

type Secret

type Secret struct {
	// the unique reference for the secret
	Name string `yaml:"name" json:"name"`
	// a description of the intended use or meaning of this secret
	Description string `yaml:"description" json:"description"`
	// the value of the secret
	Value string `yaml:"value,omitempty" json:"value,omitempty"`
	// the value is required
	Required bool `yaml:"required,omitempty" json:"required,omitempty"`
}

Secret describes the secrets required by functions

type Secrets

type Secrets []*Secret

func (Secrets) Append

func (list Secrets) Append(s *Secret) Secrets

func (Secrets) Get

func (list Secrets) Get(ix int) *Secret

func (Secrets) GetByName

func (list Secrets) GetByName(name string) *Secret

func (Secrets) Len

func (list Secrets) Len() int

func (Secrets) Less

func (list Secrets) Less(i, j int) bool

func (Secrets) Swap

func (list Secrets) Swap(i, j int)

type Tag

type Tag struct {
	Name string `yaml:"name"`
	Min  int    `yaml:"min,omitempty"`
	Max  int    `yaml:"max,omitempty"`
}

type Var

type Var struct {
	Name        string `yaml:"name" json:"name"`
	Description string `yaml:"description" json:"description"`
	Required    bool   `yaml:"required" json:"required"`
	Type        string `yaml:"type" json:"type"`
	Value       string `yaml:"value,omitempty" json:"value,omitempty"`
	Default     string `yaml:"default,omitempty" json:"default,omitempty"`
}

type Vars

type Vars []*Var

func (Vars) Append

func (list Vars) Append(v *Var) Vars

func (Vars) Get

func (list Vars) Get(ix int) *Var

func (Vars) GetByName

func (list Vars) GetByName(name string) *Var

func (Vars) Len

func (list Vars) Len() int

func (Vars) Less

func (list Vars) Less(i, j int) bool

func (Vars) Swap

func (list Vars) Swap(i, j int)

type VerifyHandler

type VerifyHandler func(name *core.PackageName, seal *Seal, path string, authorisedAuthors []string, flags uint8) error

Jump to

Keyboard shortcuts

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