common

package
v0.0.0-...-706a057 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2018 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FunctionsDockerImage     = "fnproject/fnserver"
	FuncfileDockerRuntime    = "docker"
	MinRequiredDockerVersion = "17.5.0"
)

Global docker variables.

View Source
const LatestYamlVersion = 20180708
View Source
const V20180708Schema = `` /* 1245-byte string literal not displayed */

Variables

View Source
var (
	// InitialVersion - inital fn version.
	InitialVersion = "0.0.1"
)

Functions

func BumpCommand

func BumpCommand() cli.Command

BumpCommand command to build function version.

func DockerPush

func DockerPush(ff *FuncFile) error

DockerPush pushes to docker registry.

func DockerPushV20180708

func DockerPushV20180708(ff *FuncFileV20180708) error

DockerPush pushes to docker registry.

func EncodeFuncFileV20180708YAML

func EncodeFuncFileV20180708YAML(path string, ff *FuncFileV20180708) error

EncodeFuncfileYAML encodes function file.

func EncodeFuncfileYAML

func EncodeFuncfileYAML(path string, ff *FuncFile) error

EncodeFuncfileYAML encodes function file.

func Exists

func Exists(name string) bool

Exists check file exists.

func ExtractAnnotations

func ExtractAnnotations(c *cli.Context) map[string]interface{}

ExtractAnnotations extract annotations from command flags.

func ExtractConfig

func ExtractConfig(configs []string) map[string]string

ExtractConfig parses key-value configuration into a map

func FindFuncfile

func FindFuncfile(path string) (string, error)

findFuncfile for a func.yaml/json/yml file in path

func GetDir

func GetDir(c *cli.Context) string

GetDir returns the dir if defined as a flag in cli.Context

func GetFuncYamlVersion

func GetFuncYamlVersion(oldFF map[string]interface{}) int

func GetWd

func GetWd() string

GetWd returns working directory.

func IsFuncFile

func IsFuncFile(path string, info os.FileInfo) bool

IsFuncFile check vaid funcfile.

func PrintContextualInfo

func PrintContextualInfo()

func ReadInFuncFile

func ReadInFuncFile() (map[string]interface{}, error)

func RunBuild

func RunBuild(verbose bool, dir, imageName, dockerfile string, buildArgs []string, noCache bool) error

RunBuild runs function from func.yaml/json/yml.

func ValidateFileAgainstSchema

func ValidateFileAgainstSchema(jsonFile, schema string) error

func ValidateFullImageName

func ValidateFullImageName(n string) error

ValidateFullImageName validates that the full image name (REGISTRY/name:tag) is allowed for push remember that private registries must be supported here

func ValidateTagImageName

func ValidateTagImageName(n string) error

ValidateTagImageName validates that the last part of the image name (name:tag) is allowed for create/update

func WalkFuncs

func WalkFuncs(root string, walkFn walkFuncsFunc) error

WalkFuncs is similar to filepath.Walk except only returns func.yaml's (so on per function)

func WalkFuncsV20180708

func WalkFuncsV20180708(root string, walkFn walkFuncsFuncV20180708) error

WalkFuncs is similar to filepath.Walk except only returns func.yaml's (so on per function)

Types

type AppFile

type AppFile struct {
	Name string `yaml:"name,omitempty" json:"name,omitempty"`
	// TODO: Config here is not yet used
	Config      map[string]string      `yaml:"config,omitempty" json:"config,omitempty"`
	Annotations map[string]interface{} `yaml:"annotations,omitempty" json:"annotations,omitempty"`
}

AppFile defines the internal structure of a app.yaml/json/yml

func LoadAppfile

func LoadAppfile(path string) (*AppFile, error)

LoadAppfile returns a parsed appfile.

type Expects

type Expects struct {
	Config []inputVar `yaml:"config" json:"config"`
}

Expects represents expected env vars in funcfile.

type FFTest

type FFTest struct {
	Name   string     `yaml:"name,omitempty" json:"name,omitempty"`
	Input  *InputMap  `yaml:"input,omitempty" json:"input,omitempty"`
	Output *OutputMap `yaml:"outoutput,omitempty" json:"output,omitempty"`
	Err    *string    `yaml:"err,omitempty" json:"err,omitempty"`
}

FFTest represents a test for a funcfile.

type FuncFile

type FuncFile struct {
	Name string `yaml:"name,omitempty" json:"name,omitempty"`

	// Build params
	Version     string   `yaml:"version,omitempty" json:"version,omitempty"`
	Runtime     string   `yaml:"runtime,omitempty" json:"runtime,omitempty"`
	Entrypoint  string   `yaml:"entrypoint,omitempty" json:"entrypoint,omitempty"`
	Cmd         string   `yaml:"cmd,omitempty" json:"cmd,omitempty"`
	Build       []string `yaml:"build,omitempty" json:"build,omitempty"`
	Tests       []FFTest `yaml:"tests,omitempty" json:"tests,omitempty"`
	BuildImage  string   `yaml:"build_image,omitempty" json:"build_image,omitempty"` // Image to use as base for building
	RunImage    string   `yaml:"run_image,omitempty" json:"run_image,omitempty"`     // Image to use for running
	ContentType string   `yaml:"content_type,omitempty" json:"content_type,omitempty"`

	// Route params
	// TODO embed models.Route
	Type        string                 `yaml:"type,omitempty" json:"type,omitempty"`
	Memory      uint64                 `yaml:"memory,omitempty" json:"memory,omitempty"`
	Cpus        string                 `yaml:"cpus,omitempty" json:"cpus,omitempty"`
	Format      string                 `yaml:"format,omitempty" json:"format,omitempty"`
	Timeout     *int32                 `yaml:"timeout,omitempty" json:"timeout,omitempty"`
	Path        string                 `yaml:"path,omitempty" json:"path,omitempty"`
	Config      map[string]string      `yaml:"config,omitempty" json:"config,omitempty"`
	Headers     map[string][]string    `yaml:"headers,omitempty" json:"headers,omitempty"`
	IDLETimeout *int32                 `yaml:"idle_timeout,omitempty" json:"idle_timeout,omitempty"`
	Annotations map[string]interface{} `yaml:"annotations,omitempty" json:"annotations,omitempty"`

	// Run/test
	Expects Expects `yaml:"expects,omitempty" json:"expects,omitempty"`
}

FuncFile defines the internal structure of a func.yaml/json/yml

func BuildFunc

func BuildFunc(verbose bool, fpath string, funcfile *FuncFile, buildArg []string, noCache bool) (*FuncFile, error)

BuildFunc bumps version and builds function.

func BumpIt

func BumpIt(fpath string, vtype VType) (*FuncFile, error)

BumpIt returns updated funcfile

func FindAndParseFuncfile

func FindAndParseFuncfile(path string) (fpath string, ff *FuncFile, err error)

FindAndParseFuncfile for a func.yaml/json/yml file.

func LoadFuncfile

func LoadFuncfile(path string) (string, *FuncFile, error)

LoadFuncfile returns a parsed funcfile.

func ParseFuncfile

func ParseFuncfile(path string) (*FuncFile, error)

ParseFuncfile check file type to decode and parse.

func (*FuncFile) ImageName

func (ff *FuncFile) ImageName() string

ImageName returns the name of a funcfile image

func (*FuncFile) RuntimeTag

func (ff *FuncFile) RuntimeTag() (runtime, tag string)

RuntimeTag returns the runtime and tag.

type FuncFileV20180708

type FuncFileV20180708 struct {
	Schema_version int `yaml:"schema_version,omitempty" json:"schema_version,omitempty"`

	Name         string `yaml:"name,omitempty" json:"name,omitempty"`
	Version      string `yaml:"version,omitempty" json:"version,omitempty"`
	Runtime      string `yaml:"runtime,omitempty" json:"runtime,omitempty"`
	Build_image  string `yaml:"build_image,omitempty" json:"build_image,omitempty"` // Image to use as base for building
	Run_image    string `yaml:"run_image,omitempty" json:"run_image,omitempty"`     // Image to use for running
	Cmd          string `yaml:"cmd,omitempty" json:"cmd,omitempty"`
	Entrypoint   string `yaml:"entrypoint,omitempty" json:"entrypoint,omitempty"`
	Content_type string `yaml:"content_type,omitempty" json:"content_type,omitempty"`
	Format       string `yaml:"format,omitempty" json:"format,omitempty"`
	Type         string `yaml:"type,omitempty" json:"type,omitempty"`
	Memory       uint64 `yaml:"memory,omitempty" json:"memory,omitempty"`
	Timeout      *int32 `yaml:"timeout,omitempty" json:"timeout,omitempty"`
	IDLE_timeout *int32 `yaml:"idle_timeout,omitempty" json:"idle_timeout,omitempty"`

	Config      map[string]string      `yaml:"config,omitempty" json:"config,omitempty"`
	Annotations map[string]interface{} `yaml:"annotations,omitempty" json:"annotations,omitempty"`

	Build []string `yaml:"build,omitempty" json:"build,omitempty"`

	Expects  Expects   `yaml:"expects,omitempty" json:"expects,omitempty"`
	Triggers []Trigger `yaml:"triggers,omitempty" json:"triggers,omitempty"`
}

FuncFileV20180708 defines the latest internal structure of a func.yaml/json/yml

func BuildFuncV20180708

func BuildFuncV20180708(verbose bool, fpath string, funcfile *FuncFileV20180708, buildArg []string, noCache bool) (*FuncFileV20180708, error)

BuildFunc bumps version and builds function.

func BumpItV20180708

func BumpItV20180708(fpath string, vtype VType) (*FuncFileV20180708, error)

BumpIt returns updated funcfile

func FindAndParseFuncFileV20180708

func FindAndParseFuncFileV20180708(path string) (fpath string, ff *FuncFileV20180708, err error)

func LoadFuncFileV20180708

func LoadFuncFileV20180708(path string) (string, *FuncFileV20180708, error)

func ParseFuncFileV20180708

func ParseFuncFileV20180708(path string) (*FuncFileV20180708, error)

func (*FuncFileV20180708) ImageNameV20180708

func (ff *FuncFileV20180708) ImageNameV20180708() string

ImageName returns the name of a funcfile image

type InputMap

type InputMap struct {
	Body interface{}
}

InputMap to be used within FFTest.

type NotFoundError

type NotFoundError struct {
	S string
}

NotFoundError represents error string.

func NewNotFoundError

func NewNotFoundError(s string) *NotFoundError

NewNotFoundError returns a new error.

func (*NotFoundError) Error

func (e *NotFoundError) Error() string

type OutputMap

type OutputMap struct {
	Body interface{}
}

OutputMap to be used within FFTest.

type Trigger

type Trigger struct {
	Name   string `yaml:"name,omitempty" json:"name,omitempty"`
	Type   string `yaml:"type,omitempty" json:"type,omitempty"`
	Source string `yaml:"source,omitempty" json:"source,omitempty"`
}

Trigger represents a trigger for a FuncFileV20180708

type VType

type VType int

VType represents the version type

const (
	Patch VType = iota
	Minor
	Major
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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