environment

package
v0.0.0-...-614ca16 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2023 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultPasswordAlphabet = "ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz23456789"
)

Variables

This section is empty.

Functions

func SecureRandomPassword

func SecureRandomPassword(alphabet string, length int) string

Types

type Builder

type Builder struct {
	// contains filtered or unexported fields
}

func (Builder) Build

func (b Builder) Build() (*Environment, error)

func (Builder) WithBrn

func (b Builder) WithBrn(brn brns.StackBrn) Builder

func (Builder) WithCluster

func (b Builder) WithCluster(name string) Builder

func (Builder) WithEnvironment

func (b Builder) WithEnvironment(env Config) Builder

func (Builder) WithStack

func (b Builder) WithStack(name string) Builder

type Command

type Command struct {
	FromPath string                `yaml:"fromPath,omitempty" json:"fromPath,omitempty"`
	Name     string                `yaml:"name" json:"name"`
	Exec     *command.CommandValue `yaml:"exec,omitempty" json:"exec,omitempty"`
}

type Config

type Config struct {
	core.ConfigShared `yaml:",inline"`
	Role              core.EnvironmentRole `yaml:"role" json:"role"`
	ClusterRoles      []string             `yaml:"clusterRoles,omitempty" json:"clusterRoles,omitempty"`
	DefaultCluster    string               `yaml:"defaultCluster,omitempty" json:"defaultCluster"`
	Clusters          kube.ClusterConfigs  `yaml:"clusters,omitempty"`
	PullSecrets       []kube.PullSecret    `yaml:"pullSecrets,omitempty"`
	VaultNamespace    string               `yaml:"vaultNamespace,omitempty" json:"vaultNamespace,omitempty"`
	// If true, commands which would cause modifications to be deployed will
	// trigger a confirmation prompt.
	Protected bool                             `yaml:"protected" json:"protected"`
	IsLocal   bool                             `yaml:"isLocal" json:"isLocal"`
	Commands  []*Command                       `yaml:"commands,omitempty" json:"commands,omitempty"`
	Variables []*environmentvariables.Variable `yaml:"variables,omitempty" json:"variables,omitempty"`
	Scripts   []*script.Script                 `yaml:"scripts,omitempty" json:"scripts,omitempty"`
	// Contains app value overrides which should be applied when deploying
	// apps to this environment.
	AppValues      *values.ValueSet           `yaml:"appValues,omitempty" json:"appValues"`
	ValueSetNames  []string                   `yaml:"valueSets,omitempty" json:"valueSets,omitempty"`
	ValueOverrides *values.ValueSetCollection `yaml:"valueOverrides,omitempty"`
	// Deprecated
	AppValueOverrides map[string]values.ValueSetCollection `yaml:"appValueOverrides,omitempty"`
	// Apps which should not be deployed to this environment.
	// Deprecated
	AppBlacklist []string `yaml:"appBlacklist,omitempty"`
	// Apps which should be deployed to this environment, and any value overrides for them. If empty, all apps will be included except ones on AppBlacklist.
	Apps                 map[string]values.ValueSetCollection `yaml:"apps"`
	SecretGroupFilePaths map[string]string                    `yaml:"secretFiles"`
}

func LoadConfig

func LoadConfig(path string) (*Config, error)

func (Config) Builder

func (c Config) Builder(deps Dependencies) Builder

func (*Config) GetDefaultClusterConfig

func (e *Config) GetDefaultClusterConfig() (*kube.ClusterConfig, error)

func (*Config) MarshalYAML

func (e *Config) MarshalYAML() (interface{}, error)

func (*Config) Merge

func (e *Config) Merge(other *Config)

func (*Config) SetFromPath

func (e *Config) SetFromPath(path string)

func (*Config) UnmarshalYAML

func (e *Config) UnmarshalYAML(unmarshal func(interface{}) error) error

type Dependencies

type Dependencies interface {
	environmentvariables.Dependencies
	WithEnv(environment *Environment) interface{}
}

type Environment

type Environment struct {
	Config
	// contains filtered or unexported fields
}

func (*Environment) AddOrUpdateSecretValue

func (e *Environment) AddOrUpdateSecretValue(groupName string, secretName string, value string) error

func (*Environment) AddSecretGroup

func (e *Environment) AddSecretGroup(groupName string, keyConfig *SecretKeyConfig) error

AddSecretGroup creates or replaces a secret group using the provided key config.

func (*Environment) Cluster

func (e *Environment) Cluster() *kube.Cluster

func (*Environment) ClusterForRoleExists

func (e *Environment) ClusterForRoleExists(role core.ClusterRole) bool

func (*Environment) DeleteSecretGroup

func (e *Environment) DeleteSecretGroup(groupName string) error

func (*Environment) Execute

func (*Environment) GetAppValueSetCollectionProvider

func (e *Environment) GetAppValueSetCollectionProvider(appName string) values.ValueSetCollectionProvider

GetAppValueSetCollectionProvider returns a ValuesSetCollectionProvider that will provide any values set collection defined in this environment for a specific app. If none is defined, an instance that does nothing will be returned.

func (*Environment) GetClusterConfig

func (e *Environment) GetClusterConfig() *kube.ClusterConfig

func (*Environment) GetSecretConfig

func (e *Environment) GetSecretConfig(groupName string, secretName string) (*SecretConfig, error)

func (*Environment) GetSecretGroup

func (e *Environment) GetSecretGroup(name string) (group *SecretGroup, exists bool, loadErr error)

GetSecretGroup gets the secret group with the provided name. If the group does not exist, the returned bool will be false. If the group could not be loaded, the error will not be nil.

func (*Environment) GetSecretGroupConfig

func (e *Environment) GetSecretGroupConfig(groupName string) (*SecretGroupConfig, error)

func (*Environment) GetSecretGroupConfigs

func (e *Environment) GetSecretGroupConfigs() ([]SecretGroupConfig, error)

func (*Environment) GetSecretValue

func (e *Environment) GetSecretValue(groupName string, secretName string) (string, error)

func (*Environment) GetValueSetCollection

func (e *Environment) GetValueSetCollection() values.ValueSetCollection

func (*Environment) GetVariablesAsMap

func (e *Environment) GetVariablesAsMap(ctx environmentvariables.Dependencies) (map[string]string, error)

func (*Environment) HasCluster

func (e *Environment) HasCluster() bool

func (Environment) IsAppDisabled

func (e Environment) IsAppDisabled(appName string) bool

IsAppDisabled returns true if the app is disabled for the environment. Apps are assumed to be disabled for the environment unless they are in the app list and not marked as disabled

func (Environment) Matches

func (e Environment) Matches(candidate EnvironmentFilterable) bool

func (*Environment) Render

func (*Environment) ResolveSecretPath

func (e *Environment) ResolveSecretPath(secretPath string) (string, error)

func (*Environment) Save

func (e *Environment) Save() error

func (*Environment) Stack

func (e *Environment) Stack() *kube.Stack

func (*Environment) ValidateConsistency

func (e *Environment) ValidateConsistency() error

func (*Environment) ValidateSecrets

func (e *Environment) ValidateSecrets(secretPaths ...string) error

type EnvironmentFilterable

type EnvironmentFilterable interface {
	GetEnvironmentRoles() (core.EnvironmentRoles, bool)
	GetEnvironmentName() (string, bool)
}

type Environmenter

type Environmenter interface {
	Environment() Environment
}

type LastpassKeyConfig

type LastpassKeyConfig struct {
	Path  string `yaml:"path"`
	Field string `yaml:"field"`
}

type SecretConfig

type SecretConfig struct {
	Name        string                  `yaml:"name"`
	Description string                  `yaml:"description"`
	Generation  *SecretGenerationConfig `yaml:"generation,omitempty"`
}

type SecretGenerationConfig

type SecretGenerationConfig struct {
	Length int `yaml:"length"`
}

type SecretGroup

type SecretGroup struct {
	// contains filtered or unexported fields
}

func NewSecretGroup

func NewSecretGroup(config *SecretGroupConfig) (*SecretGroup, error)

Creates an in-memory secret group from the given config, with secret values decrypted.

func (*SecretGroup) AddOrUpdateSecret

func (s *SecretGroup) AddOrUpdateSecret(value string, config *SecretConfig) error

AddOrUpdateSecretValue adds or replaces an existing secret, then saves the group.

func (*SecretGroup) AddOrUpdateSecretValue

func (s *SecretGroup) AddOrUpdateSecretValue(name string, value string) error

func (*SecretGroup) DeleteAllSecretValues

func (s *SecretGroup) DeleteAllSecretValues() error

DeleteAllSecretValues drops all secret values, then saves the group.

func (*SecretGroup) DeleteSecretConfig

func (s *SecretGroup) DeleteSecretConfig(name string) error

DeleteSecretConfig deletes a secret config (and the value) from the group, then saves the group.

func (*SecretGroup) DeleteSecretValue

func (s *SecretGroup) DeleteSecretValue(name string) error

DeleteSecret deletes the value of a secret (but not the config) from the group, then saves the group.

func (*SecretGroup) GetSecretValue

func (s *SecretGroup) GetSecretValue(name string, generationConfig *SecretGenerationConfig) (string, error)

func (*SecretGroup) Save

func (s *SecretGroup) Save() error

Save encrypts the secret values and saves them to disk.

type SecretGroupConfig

type SecretGroupConfig struct {
	core.ConfigShared `yaml:",inline"`
	Secrets           []*SecretConfig  `yaml:"secrets"`
	Key               *SecretKeyConfig `yaml:"key"`

	SecretValues string `yaml:"secretValues"`
	// contains filtered or unexported fields
}

type SecretKeyConfig

type SecretKeyConfig struct {
	Prompt                 bool               `yaml:"prompt,omitempty"`
	EnvironmentVariable    string             `yaml:"environmentVariable,omitempty"`
	UnsafeStoredPassphrase string             `yaml:"UNSAFE,omitempty"`
	Lastpass               *LastpassKeyConfig `yaml:"lastpass,omitempty"`
	Nonce                  string             `yaml:"nonce"`
	Salt                   string             `yaml:"salt"`
	// contains filtered or unexported fields
}

func (*SecretKeyConfig) GetKeyComponents

func (s *SecretKeyConfig) GetKeyComponents(secretGroupName string) (key []byte, nonce []byte, err error)

type SecretPath

type SecretPath struct {
	GroupName  string
	SecretName string
	Generation *SecretGenerationConfig
}

func ParseSecretPath

func ParseSecretPath(in string) (*SecretPath, error)

type SecretValues

type SecretValues struct {
	Values map[string]string `yaml:"values"`
	Dirty  bool              `yaml:"-"`
}

Jump to

Keyboard shortcuts

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