Version: v0.3.0 Latest Latest

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

Go to latest
Published: Jan 30, 2018 License: BSD-3-Clause Imports: 9 Imported by: 0




This section is empty.


View Source
var SupportedRuntimes []RuntimeType = []RuntimeType{


func BootCmdForScript

func BootCmdForScript(bootNames []string) string

BootCmdForScript returns boot command that is to be used to run config set with name bootName.

func PrependEnvsPrefix

func PrependEnvsPrefix(cmd string, env map[string]string, soft bool) (string, error)

PrependEnvsPrefix prepends all key-values of env map to the boot cmd give. It prepends each pair in a form of "--env={KEY}={VALUE}". Also performs check that neither key nor value contains space. Argument `soft` means that operator '?=' is used that only sets env variable if it's not set yet.


type AllCmdConfigs added in v0.3.0

type AllCmdConfigs struct {
	// contains filtered or unexported fields

AllCmdConfigs is a result that parsing meta/run.yamls of all required packages yields.

func (*AllCmdConfigs) Add added in v0.3.0

func (c *AllCmdConfigs) Add(pkgName string, cmdConfig *CmdConfig)

func (*AllCmdConfigs) Persist added in v0.3.0

func (c *AllCmdConfigs) Persist(mpmDir string) error

type CmdConfig added in v0.3.0

type CmdConfig struct {
	RuntimeType      RuntimeType
	ConfigSetDefault string

	// ConfigSets is a map of available <config-name>:<runtime> pairs.
	// The map is built based on meta/run.yaml.
	ConfigSets map[string]Runtime

CmdConfig is a result that parsing meta/run.yaml yields.

func ParsePackageRunManifestData added in v0.3.0

func ParsePackageRunManifestData(cmdConfigData []byte) (*CmdConfig, error)

ParsePackageRunManifestData returns parsed manifest data.

type CommonRuntime

type CommonRuntime struct {
	Env  map[string]string `yaml:"env"`
	Base string            `yaml:"base"`

CommonRuntime fields are those common to all runtimes. This fields are set for each named-configuration separately, nothing is shared.

func (CommonRuntime) BuildBootCmd

func (r CommonRuntime) BuildBootCmd(bootCmd string, cmdConfs map[string]*CmdConfig, env map[string]string) (string, error)

BuildBootCmd equips runtime-specific bootcmd with common parts.

func (CommonRuntime) GetYamlTemplate

func (r CommonRuntime) GetYamlTemplate() string

func (CommonRuntime) Validate

func (r CommonRuntime) Validate() error

type RunConfig

type RunConfig struct {
	InstanceName string // general
	Verbose      bool
	GCEUploadDir string
	Cmd          string
	Persist      bool
	Hypervisor   string
	ImageName    string // storage
	Volumes      []string
	Memory       string // resources
	Cpus         int
	Networking   string // networking
	Bridge       string
	NatRules     []nat.Rule
	MAC          string

type Runtime

type Runtime interface {
	// Validate values that were read from yaml.
	Validate() error

	// GetBootCmd produces bootcmd based on meta/run.yaml. The cmdConfs
	// argument contains CmdConfig objects for all required packages and
	// can be used when building boot command.
	GetBootCmd(cmdConfs map[string]*CmdConfig, env map[string]string) (string, error)

	// GetRuntimeName returns unique runtime name
	// (use constant from the SupportedRuntimes list)
	GetRuntimeName() string

	// GetRuntimeDescription provides short description about what
	// is this runtime used for, 50 chars
	GetRuntimeDescription() string

	// GetYamlTemplate provides a string containing yaml content with
	// as much help text as possible.
	// NOTE: provide only runtime-specific part of yaml, see runtime/node.go for example.
	// NOTE: Write each comment in its own line for --plain flag to remove it.
	GetYamlTemplate() string

	// GetDependencies returns a list of dependent package names.
	GetDependencies() []string

Runtime interface must be extended for every new runtime. Typically, a runtime struct contains fileds that are expected in meta/run.yaml and implements the functions required by this interface.

func PackageRunManifestGeneral added in v0.3.0

func PackageRunManifestGeneral(cmdConfigFile string) (Runtime, error)

PackageRunManifestGeneral parses meta/run.yaml file into blank RunConfig. By 'blank' we mean that the struct has no fields populated, but it is of correct type i.e. appropriate implementation of Runtime interface. NOTE: We must differentiate two things regarding Runtime interface implementation:

a) what struct is it implemented with -> e.g. nodeJsRuntime
b) what fields is struct populated with -> e.g. nodeJsRuntime.Main

For a given meta/run.yaml all config sets get the same (a), but are populated
with different values for (b).

NOTE: when Capstan needs to know what packages to require, it needs (a), but

not (b). And this function returns exactly this, (a) without (b).

func PickRuntime

func PickRuntime(runtimeName RuntimeType) (Runtime, error)

PickRuntime maps runtime name into runtime struct.

type RuntimeType

type RuntimeType string
const (
	Native RuntimeType = "native"
	NodeJS RuntimeType = "node"
	Java   RuntimeType = "java"
	Python RuntimeType = "python"

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL