config

package
v0.38.13 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2022 License: Apache-2.0 Imports: 6 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"

	// EnvInstallationName is the name of the environment variable containing the name of the installation.
	EnvInstallationName = "CNAB_INSTALLATION_NAME"

	// EnvACTION is the requested action to be executed
	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"

	// CustomPorterKey is the key in the bundle.json custom section that contains the Porter stamp
	// It holds all the metadata that Porter includes that is specific to Porter about the bundle.
	CustomPorterKey = "sh.porter"

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

	// ClaimFilepath is the filepath to the claim.json inside of an invocation image
	ClaimFilepath = "/cnab/claim.json"
)

Variables

This section is empty.

Functions

func NoopDataLoader

func NoopDataLoader(config *Config) error

NoopDataLoader skips loading the datastore.

Types

type Config

type Config struct {
	*context.Context
	Data       *Data
	DataLoader DataStoreLoaderFunc

	// ConfigFilePath is the path to the loaded configuration file
	ConfigFilePath string
	// contains filtered or unexported fields
}

func New

func New() *Config

New Config initializes a default porter configuration.

func (*Config) GetBundleArchiveLogs

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

GetArchiveLogs locates the output for Bundle Archive Operations.

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 absolute path to the porter home directory. Hierarchy of checks: - PORTER_HOME - HOME/.porter or USERPROFILE/.porter

func (*Config) GetPluginPath

func (c *Config) GetPluginPath(plugin string) (string, error)

func (*Config) GetPluginsDir

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

func (*Config) GetPorterPath

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

func (*Config) LoadData

func (c *Config) LoadData() error

LoadData from the datastore in PORTER_HOME. This defaults to doing nothing unless DataLoader has been set.

func (*Config) SetHomeDir

func (c *Config) SetHomeDir(home string)

SetHomeDir is a test function that allows tests to use an alternate Porter home directory.

func (*Config) SetPorterPath added in v0.30.1

func (c *Config) SetPorterPath(path string)

SetPorterPath is a test function that allows tests to use an alternate Porter binary location.

type CrudStore

type CrudStore struct {
	PluginConfig `mapstructure:",squash"`
}

CrudStore is the plugin stanza for storage.

type Data

type Data struct {

	// DefaultStoragePlugin is the storage plugin to use when no named storage is specified.
	DefaultStoragePlugin string `mapstructure:"default-storage-plugin"`

	// DefaultStorage to use when a named storage is not specified by a flag.
	DefaultStorage string `mapstructure:"default-storage"`

	// CrudStores defined in the configuration file.
	CrudStores []CrudStore `mapstructure:"storage"`

	// DefaultSecretsPlugin is the plugin to use when no plugin is specified.
	DefaultSecretsPlugin string `mapstructure:"default-secrets-plugin"`

	// DefaultSecrets to use when one is not specified by a flag.
	DefaultSecrets string `mapstructure:"default-secrets"`

	// SecretSources defined in the configuration file.
	SecretSources []SecretSource `mapstructure:"secrets"`
}

Data is the data stored in PORTER_HOME/porter.toml|yaml|json. Use the accessor functions to ensure default values are handled properly.

func (*Data) GetDefaultSecretSource

func (d *Data) GetDefaultSecretSource() string

func (*Data) GetDefaultSecretsPlugin

func (d *Data) GetDefaultSecretsPlugin() string

func (*Data) GetDefaultStorage

func (d *Data) GetDefaultStorage() string

func (*Data) GetDefaultStoragePlugin

func (d *Data) GetDefaultStoragePlugin() string

func (*Data) GetSecretSource

func (d *Data) GetSecretSource(name string) (SecretSource, error)

func (*Data) GetStorage

func (d *Data) GetStorage(name string) (CrudStore, error)

type DataStoreLoaderFunc

type DataStoreLoaderFunc func(*Config) error

type PluginConfig

type PluginConfig struct {
	Name         string                 `mapstructure:"name"`
	PluginSubKey string                 `mapstructure:"plugin"`
	Config       map[string]interface{} `mapstructure:"config"`
}

PluginConfig is a standardized config stanza that defines which plugin to use and its custom configuration.

func (PluginConfig) GetConfig

func (p PluginConfig) GetConfig() interface{}

func (PluginConfig) GetName

func (p PluginConfig) GetName() string

func (PluginConfig) GetPluginSubKey

func (p PluginConfig) GetPluginSubKey() string

type SecretSource

type SecretSource struct {
	PluginConfig `mapstructure:",squash"`
}

SecretSource is the plugin stanza for secrets.

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() (testDir string, homeDir string)

SetupIntegrationTest initializes the filesystem with the supporting files in a temp PORTER_HOME directory.

func (*TestConfig) SetupUnitTest added in v0.31.0

func (c *TestConfig) SetupUnitTest()

SetupUnitTest initializes the unit test filesystem with the supporting files in the PORTER_HOME directory.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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