config

package
v0.1.0-raplpha....-c86f6ab Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2018 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Name is the file name of the porter configuration file.
	Name = "porter.yaml"

	// RunScript is the path to the CNAB run script.
	RunScript = "cnab/app/run"

	// EnvHOME is the name of the environment variable containing the porter home directory path.
	EnvHOME = "PORTER_HOME"

	// EnvACTION is the request
	EnvACTION = "CNAB_ACTION"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action string
const (
	ActionInstall   Action = "install"
	ActionUpgrade   Action = "upgrade"
	ActionUninstall Action = "uninstall"
)

func ParseAction

func ParseAction(value string) (Action, error)

type BundleConnection

type BundleConnection struct {
	Source      string `yaml:source`
	Destination string `yaml:destination`
}

type BundleOutput

type BundleOutput struct {
	Name                string `yaml:"name"`
	Path                string `yaml:"path"`
	EnvironmentVariable string `yaml:"env"`
}

type Config

type Config struct {
	*context.Context
	Manifest *Manifest
}

func New

func New() *Config

New Config initializes a default porter configuration.

func (*Config) GetBundleDir

func (c *Config) GetBundleDir(bundle string) (string, error)

GetBundleDir locates a bundle Lookup order: - ./bundles/ - PORTER_HOME/bundles/

func (*Config) GetBundleManifestPath

func (c *Config) GetBundleManifestPath(bundle string) (string, error)

GetBundleManifest gets the path to another bundle's manifest.

func (*Config) GetBundlesCache

func (c *Config) GetBundlesCache() (string, error)

GetBundlesDir locates the bundle cache from the porter home directory.

func (*Config) GetHomeDir

func (c *Config) GetHomeDir() (string, error)

GetHomeDir determines the path to the porter home directory.

func (*Config) GetMixinDir

func (c *Config) GetMixinDir(mixin string) (string, error)

func (*Config) GetMixinPath

func (c *Config) GetMixinPath(mixin string) (string, error)

func (*Config) GetMixinRuntimePath

func (c *Config) GetMixinRuntimePath(mixin string) (string, error)

func (*Config) GetMixinsDir

func (c *Config) GetMixinsDir() (string, error)

func (*Config) GetPorterConfigTemplate

func (c *Config) GetPorterConfigTemplate() ([]byte, error)

GetPorterConfigTemplate reads templates/porter.yaml from the porter home directory.

func (*Config) GetRunScriptTemplate

func (c *Config) GetRunScriptTemplate() ([]byte, error)

GetRunScriptTemplate reads templates/run from the porter home directory.

func (*Config) GetTemplatesDir

func (c *Config) GetTemplatesDir() (string, error)

GetTemplatesDir determines the path to the templates directory.

func (*Config) LoadDependencies

func (c *Config) LoadDependencies() error

func (*Config) LoadManifest

func (c *Config) LoadManifest() error

func (*Config) LoadManifestFrom

func (c *Config) LoadManifestFrom(file string) error

func (*Config) ReadManifest

func (c *Config) ReadManifest(path string) (*Manifest, error)

type CredentialDefinition

type CredentialDefinition struct {
	Name                string `yaml:"name"`
	Path                string `yaml:"path"`
	EnvironmentVariable string `yaml:"env"`
}

type Dependency

type Dependency struct {
	Name        string             `yaml:"name"`
	Parameters  map[string]string  `yaml:"parameters,omitempty"`
	Connections []BundleConnection `yaml:"connections",omitempty`
	// contains filtered or unexported fields
}

func (*Dependency) Validate

func (d *Dependency) Validate() error

type Location

type Location struct {
	Path                string `yaml:"path"`
	EnvironmentVariable string `yaml:"env"`
}

type Manifest

type Manifest struct {
	Name         string                 `yaml:"image,omitempty"`
	Version      string                 `yaml:"version,omitempty"`
	Image        string                 `yaml:"invocationImage,omitempty"`
	Mixins       []string               `yaml:"mixins,omitempty"`
	Install      Steps                  `yaml:"install"`
	Uninstall    Steps                  `yaml:"uninstall"`
	Parameters   []ParameterDefinition  `yaml:"parameters,omitempty"`
	Credentials  []CredentialDefinition `yaml:"credentials,omitempty"`
	Dependencies []*Dependency          `yaml:"dependencies,omitempty"`
	// contains filtered or unexported fields
}

func (*Manifest) ApplyOutputs

func (m *Manifest) ApplyOutputs(step *Step, assignments []string) error

func (*Manifest) GetManifestDir

func (m *Manifest) GetManifestDir() string

GetManifestDir returns the path to the directory that contains the manifest.

func (*Manifest) GetSteps

func (m *Manifest) GetSteps(action Action) (Steps, error)

func (*Manifest) Map

func (m *Manifest) Map(val reflect.Value) error

Map is a NOOP but implements the github.com/mitchellh/reflectwalk MapWalker interface

func (*Manifest) MapElem

func (m *Manifest) MapElem(mp, k, v reflect.Value) error

MapElem implements the github.com/mitchellh/reflectwalk MapWalker interface and handles individual map elements. It will resolve source references to their value within a porter bundle and replace the value

func (*Manifest) MergeDependency

func (m *Manifest) MergeDependency(dep *Dependency) error

func (*Manifest) MergeInstall

func (m *Manifest) MergeInstall(dep *Dependency)

func (*Manifest) MergeParameters

func (m *Manifest) MergeParameters(dep *Dependency) error

func (*Manifest) MergeUninstall

func (m *Manifest) MergeUninstall(dep *Dependency)

func (*Manifest) ResolveStep

func (m *Manifest) ResolveStep(step *Step) error

ResolveStep will walk through the Step's data and resolve any placeholder data using the definitions in the manifest, like parameters or credentials.

func (*Manifest) Slice

func (m *Manifest) Slice(val reflect.Value) error

Slice is a NOOP but implements the github.com/mitchellh/reflectwalk SliceWalker interface

func (*Manifest) SliceElem

func (m *Manifest) SliceElem(index int, val reflect.Value) error

SliceElem implements the github.com/mitchellh/reflectwalk SliceWalker interface and handles individual slice elements. It will resolve source references to their value within a porter bundle and replace the value

func (*Manifest) Struct

func (m *Manifest) Struct(val reflect.Value) error

Struct implements reflectwalk's StructWalker so that we can skip private fields

func (*Manifest) StructField

func (m *Manifest) StructField(field reflect.StructField, val reflect.Value) error

Struct implements reflectwalk's StructWalker so that we can skip private fields

func (*Manifest) Validate

func (m *Manifest) Validate() error

type ParameterDefinition

type ParameterDefinition struct {
	Name          string            `yaml:"name"`
	DataType      string            `yaml:"type"`
	DefaultValue  interface{}       `yaml:"default,omitempty"`
	AllowedValues []interface{}     `yaml:"allowed,omitempty"`
	Required      bool              `yaml:"required"`
	MinValue      *int              `yaml:"minValue,omitempty"`
	MaxValue      *int              `yaml:"maxValue,omitempty"`
	MinLength     *int              `yaml:"minLength,omitempty"`
	MaxLength     *int              `yaml:"maxLength,omitempty"`
	Metadata      ParameterMetadata `yaml:"metadata,omitempty"`
	Destination   *Location         `yaml:"destination,omitempty"`
}

ParameterDefinition defines a single parameter for a CNAB bundle

type ParameterMetadata

type ParameterMetadata struct {
	Description string `yaml:"description,omitempty"`
}

ParameterMetadata contains metadata for a parameter definition.

type Step

type Step struct {
	Description string                 `yaml:"description"`
	Outputs     []StepOutput           `yaml:"outputs"`
	Data        map[string]interface{} `yaml:",inline"`
	// contains filtered or unexported fields
}

func (*Step) GetMixinName

func (s *Step) GetMixinName() string

func (*Step) Validate

func (s *Step) Validate(m *Manifest) error

type StepOutput

type StepOutput struct {
	Name string                 `yaml:"name"`
	Data map[string]interface{} `yaml:",inline"`
	// contains filtered or unexported fields
}

type Steps

type Steps []*Step

func (Steps) Validate

func (s Steps) Validate(m *Manifest) error

type TestConfig

type TestConfig struct {
	*Config
	TestContext *context.TestContext
}

func NewTestConfig

func NewTestConfig(t *testing.T) *TestConfig

NewTestConfig initializes a configuration suitable for testing, with the output buffered, and an in-memory file system.

func (*TestConfig) SetupPorterHome

func (c *TestConfig) SetupPorterHome()

InitializePorterHome initializes the test filesystem with the supporting files in the PORTER_HOME directory.

Jump to

Keyboard shortcuts

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