config

package
v0.13.2-beta.1 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2019 License: MIT Imports: 17 Imported by: 2

Documentation

Index

Constants

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

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

	// EnvBundleName is the name of the environment variable containing the name of the bundle.
	EnvBundleName = "CNAB_BUNDLE_NAME"

	// EnvClaimName is the name of the environment variable containing the name of the claim.
	EnvClaimName = "CNAB_INSTALLATION_NAME"

	// EnvACTION is the request
	EnvACTION = "CNAB_ACTION"

	// EnvDEBUG is a custom porter parameter that signals that --debug flag has been passed through from the client to the runtime.
	EnvDEBUG = "PORTER_DEBUG"

	CustomBundleKey = "sh.porter"

	// BundleOutputsDir is the directory where outputs are expected to be placed
	// during the execution of a bundle action.
	BundleOutputsDir = "/cnab/app/outputs"
)

Variables

This section is empty.

Functions

func IsCoreAction

func IsCoreAction(value Action) bool

IsCoreAction determines if the value is a core action from the CNAB spec.

func OutputAppliesTo

func OutputAppliesTo(action string, output bundle.Output) bool

TODO: remove in favor of cnab-go logic: https://github.com/deislabs/cnab-go/pull/99

Types

type Action

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

func GetCoreActions

func GetCoreActions() []Action

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
	ManifestPath string
	// contains filtered or unexported fields
}

func New

func New() *Config

New Config initializes a default porter configuration.

func (*Config) GetBundlesCache

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

GetBundlesDir locates the bundle cache from the porter home directory.

func (*Config) GetClaimsDir

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

func (*Config) GetCredentialPath

func (c *Config) GetCredentialPath(name string) (string, error)

func (*Config) GetCredentialsDir

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

func (*Config) GetHomeDir

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

GetHomeDir determines the absolute 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) GetOutputsDir

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

func (*Config) GetPorterPath

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

func (*Config) GetPorterRuntimePath

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

func (*Config) LoadManifest

func (c *Config) LoadManifest() error

func (*Config) LoadManifestFrom

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

func (*Config) ReadBundleOutput

func (c *Config) ReadBundleOutput(name string, claim string) (*Output, error)

ReadBundleOutput reads the provided output associated with the provided bundle, via the filesystem provided by the config.Config object, returning the output's full Output representation

func (*Config) ReadManifest

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

ReadManifest determines if specified path is a URL or a filepath. After reading the data in the path it returns a Manifest and any errors

func (*Config) SetHomeDir

func (c *Config) SetHomeDir(home string)

type CredentialDefinition

type CredentialDefinition struct {
	Name        string `yaml:"name"`
	Description string `yaml:"description,omitempty"`
	Required    bool   `yaml:"required,omitempty"`

	Location `yaml:",inline"`
}

type CustomActionDefinition

type CustomActionDefinition struct {
	Description       string `yaml:"description,omitempty"`
	ModifiesResources bool   `yaml:"modifies,omitempty"`
	Stateless         bool   `yaml:"stateless,omitempty"`
}

type Dependency

type Dependency struct {
	Tag              string   `yaml:"tag"`
	Versions         []string `yaml:"versions"`
	AllowPrereleases bool     `yaml:"prereleases"`

	Parameters map[string]string `yaml:"parameters,omitempty"`
}

func (*Dependency) Validate

func (d *Dependency) Validate() error

type Location

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

TODO: use cnab-go's bundle.Location instead, once yaml tags have been added Location represents a Parameter or Credential location in an InvocationImage

type Manifest

type Manifest struct {
	Name        string `yaml:"name,omitempty"`
	Description string `yaml:"description,omitempty"`
	Version     string `yaml:"version,omitempty"`

	// Image is the name of the invocation image in the format REGISTRY/NAME:TAG
	Image string `yaml:"invocationImage,omitempty"`

	// BundleTag is the name of the bundle in the format REGISTRY/NAME:TAG
	BundleTag string `yaml:"tag"`

	// Dockerfile is the relative path to the Dockerfile template for the invocation image
	Dockerfile string `yaml:"dockerfile,omitempty"`

	Mixins []string `yaml:"mixins,omitempty"`

	Install   Steps `yaml:"install"`
	Uninstall Steps `yaml:"uninstall"`
	Upgrade   Steps `yaml:"upgrade"`

	CustomActions           map[string]Steps                  `yaml:"-"`
	CustomActionDefinitions map[string]CustomActionDefinition `yaml:"customActions,omitempty"`

	Parameters   []ParameterDefinition  `yaml:"parameters,omitempty"`
	Credentials  []CredentialDefinition `yaml:"credentials,omitempty"`
	Dependencies map[string]Dependency  `yaml:"dependencies,omitempty"`
	Outputs      []OutputDefinition     `yaml:"outputs,omitempty"`

	// ImageMap is a map of images referenced in the bundle. The mappings are mounted as a file at runtime to
	// /cnab/app/image-map.json. This data is not used by porter or any of the deislabs mixins, so only populate when you
	// plan on manually using this data in your own scripts.
	ImageMap map[string]MappedImage `yaml:"imageMap,omitempty"`
}

func UnmarshalManifest

func UnmarshalManifest(manifestData []byte) (*Manifest, error)

func (*Manifest) Validate

func (m *Manifest) Validate() error

type MappedImage

type MappedImage struct {
	Description   string            `yaml:"description"`
	ImageType     string            `yaml:"imageType"`
	Image         string            `yaml:"image"`
	OriginalImage string            `yaml:"originalImage,omitempty"`
	Digest        string            `yaml:"digest,omitempty"`
	Size          uint64            `yaml:"size,omitempty"`
	MediaType     string            `yaml:"mediaType,omitempty"`
	Labels        map[string]string `yaml:"labels,omitempty"`
}

type Output

type Output struct {
	Name      string `json:"name"`
	Sensitive bool   `json:"sensitive"`
	Type      string `json:"type"`
	Value     string `json:"value"`
}

Output represents a bundle output

func (*Output) JSONMarshal

func (o *Output) JSONMarshal() ([]byte, error)

JSONMarshal marshals an Output to JSON, returning a byte array or error

type OutputDefinition

type OutputDefinition struct {
	Name      string   `yaml:"name"`
	ApplyTo   []string `yaml:"applyTo,omitempty"`
	Sensitive bool     `yaml:"sensitive"`

	definition.Schema `yaml:",inline"`
}

OutputDefinition defines a single output for a CNAB

func (*OutputDefinition) Validate

func (od *OutputDefinition) Validate() error

type Outputs

type Outputs []Output

Outputs is a slice of Outputs

func (Outputs) Len

func (l Outputs) Len() int

func (Outputs) Less

func (l Outputs) Less(i, j int) bool

func (Outputs) Swap

func (l Outputs) Swap(i, j int)

type ParameterDefinition

type ParameterDefinition struct {
	Name      string `yaml:"name"`
	Sensitive bool   `yaml:"sensitive"`

	// These fields represent a subset of bundle.Parameter as defined in deislabs/cnab-go,
	// minus the 'Description' field (definition.Schema's will be used) and `Definition` field
	ApplyTo     []string  `yaml:"applyTo,omitempty"`
	Destination *Location `yaml:"destination,omitempty"`

	definition.Schema `yaml:",inline"`
}

ParameterDefinition defines a single parameter for a CNAB bundle

type RuntimeManifest

type RuntimeManifest struct {
	*Manifest
	*context.Context

	Action Action
	// contains filtered or unexported fields
}

func NewRuntimeManifest

func NewRuntimeManifest(cxt *context.Context, action Action, manifest *Manifest) RuntimeManifest

func (*RuntimeManifest) ApplyStepOutputs

func (m *RuntimeManifest) ApplyStepOutputs(step *Step, assignments map[string]string) error

func (*RuntimeManifest) GetSensitiveValues

func (m *RuntimeManifest) GetSensitiveValues() []string

func (*RuntimeManifest) GetSteps

func (m *RuntimeManifest) GetSteps() Steps

func (*RuntimeManifest) ResolveStep

func (m *RuntimeManifest) 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 (*RuntimeManifest) Validate

func (m *RuntimeManifest) Validate() error

type Step

type Step struct {
	Data map[string]interface{} `yaml:",inline"`
}

func (*Step) GetDescription

func (s *Step) GetDescription() (string, error)

GetDescription returns a description of the step. Every step must have this property.

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) SetupIntegrationTest

func (c *TestConfig) SetupIntegrationTest(home string)

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

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