config

package
v0.9.0-beta.1 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2019 License: MIT Imports: 13 Imported by: 11

Documentation

Index

Constants

View Source
const (
	ActionInstall    Action = "install"
	ActionUpgrade    Action = "upgrade"
	ActionUninstall  Action = "uninstall"
	ErrInvalidAction string = "invalid action"
)
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"

	// 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"
)

Variables

This section is empty.

Functions

func IsInvalidActionError

func IsInvalidActionError(err error) bool

IsInvalidActionError determines if an error is the error returned by ParseAction when a value isn't a valid action.

func IsSupportedAction

func IsSupportedAction(value string) bool

IsSupportedAction determines if the value is an action supported by Porter.

Types

type Action

type Action string

func GetSupportActions

func GetSupportActions() []Action

func ParseAction

func ParseAction(value string) (Action, error)

ParseAction converts a string into an Action, or returns an error message.

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

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

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

func (*Config) GetPorterRuntimePath

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

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)

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"`
	Path                string `yaml:"path,omitempty"`
	EnvironmentVariable string `yaml:"env,omitempty"`
}

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 ImagePlatform

type ImagePlatform struct {
	Architecture string `yaml:"architecture,omitempty"`
	OS           string `yaml:"os,omitempty"`
}

type Location

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

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"`
	Parameters   []ParameterDefinition  `yaml:"parameters,omitempty"`
	Credentials  []CredentialDefinition `yaml:"credentials,omitempty"`
	Dependencies []*Dependency          `yaml:"dependencies,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"`
	// 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) GetManifestPath

func (m *Manifest) GetManifestPath() string

GetManifestPath returns the path where the manifest was loaded. May be a URL.

func (*Manifest) GetSensitiveValues

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

func (*Manifest) GetSteps

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

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

func (m *Manifest) MergeUpgrade(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) 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"`
	Platform      *ImagePlatform `yaml:"platform,omitempty"`
}

type ParameterDefinition

type ParameterDefinition struct {
	Name          string            `yaml:"name"`
	DataType      string            `yaml:"type"`
	Default       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"`
	Sensitive     bool              `yaml:"sensitive"`
}

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 {
	Data map[string]interface{} `yaml:",inline"`
	// contains filtered or unexported fields
}

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