env

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2025 License: MPL-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AwsEnvPrinter

type AwsEnvPrinter struct {
	BaseEnvPrinter
}

AwsEnvPrinter is a struct that simulates an AWS environment for testing purposes.

func NewAwsEnvPrinter

func NewAwsEnvPrinter(injector di.Injector) *AwsEnvPrinter

NewAwsEnvPrinter initializes a new awsEnv instance using the provided dependency injector.

func (*AwsEnvPrinter) GetEnvVars

func (e *AwsEnvPrinter) GetEnvVars() (map[string]string, error)

GetEnvVars retrieves the environment variables for the AWS environment.

func (*AwsEnvPrinter) Print

func (e *AwsEnvPrinter) Print() error

Print prints the environment variables for the AWS environment.

type BaseEnvPrinter

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

Env is a struct that implements the EnvPrinter interface.

func NewBaseEnvPrinter

func NewBaseEnvPrinter(injector di.Injector) *BaseEnvPrinter

NewBaseEnvPrinter creates a new BaseEnvPrinter instance.

func (*BaseEnvPrinter) GetAlias added in v0.3.0

func (e *BaseEnvPrinter) GetAlias() (map[string]string, error)

GetAlias is a placeholder for creating an alias for a command.

func (*BaseEnvPrinter) GetEnvVars

func (e *BaseEnvPrinter) GetEnvVars() (map[string]string, error)

GetEnvVars is a placeholder for retrieving environment variables.

func (*BaseEnvPrinter) Initialize

func (e *BaseEnvPrinter) Initialize() error

Initialize resolves and assigns the shell and configHandler from the injector.

func (*BaseEnvPrinter) PostEnvHook

func (e *BaseEnvPrinter) PostEnvHook() error

PostEnvHook simulates running any necessary commands after the environment variables have been set.

func (*BaseEnvPrinter) Print

func (e *BaseEnvPrinter) Print(customVars ...map[string]string) error

Print outputs the environment variables to the console. If a map of key:value strings is provided, it prints those instead.

type CustomEnvPrinter added in v0.5.0

type CustomEnvPrinter struct {
	BaseEnvPrinter
	// contains filtered or unexported fields
}

CustomEnvPrinter is a struct that implements the EnvPrinter interface and handles custom environment variables.

func NewCustomEnvPrinter added in v0.5.0

func NewCustomEnvPrinter(injector di.Injector) *CustomEnvPrinter

NewCustomEnvPrinter initializes a new CustomEnvPrinter instance using the provided dependency injector.

func (*CustomEnvPrinter) GetEnvVars added in v0.5.0

func (e *CustomEnvPrinter) GetEnvVars() (map[string]string, error)

GetEnvVars retrieves environment variables and resolves secret placeholders. Caching avoids re-parsing if the variable is set and context is unchanged. It checks WINDSOR_CONTEXT to decide on caching strategy. Skips parsing if caching is enabled and value lacks "<ERROR". Iterates over variables, resolves secrets, and returns the map.

func (*CustomEnvPrinter) Initialize added in v0.5.1

func (e *CustomEnvPrinter) Initialize() error

Initialize sets up the CustomEnvPrinter, including resolving secrets providers.

func (*CustomEnvPrinter) Print added in v0.5.0

func (e *CustomEnvPrinter) Print() error

Print outputs the environment variables to the console.

type DockerEnvPrinter

type DockerEnvPrinter struct {
	BaseEnvPrinter
}

DockerEnvPrinter is a struct that simulates a Docker environment for testing purposes.

func NewDockerEnvPrinter

func NewDockerEnvPrinter(injector di.Injector) *DockerEnvPrinter

NewDockerEnvPrinter initializes a new dockerEnv instance using the provided dependency injector.

func (*DockerEnvPrinter) GetAlias added in v0.3.0

func (e *DockerEnvPrinter) GetAlias() (map[string]string, error)

GetAlias creates an alias for a command and returns it in a map. In this case, it looks for docker-cli-plugin-docker-compose and creates an alias for docker-compose.

func (*DockerEnvPrinter) GetEnvVars

func (e *DockerEnvPrinter) GetEnvVars() (map[string]string, error)

GetEnvVars returns Docker-specific env vars, setting DOCKER_HOST based on vm.driver config. It uses the user's home directory for Docker paths, defaulting WINDSORCONFIG if unset. Ensures Docker config directory exists and writes config if content differs. Adds DOCKER_CONFIG and REGISTRY_URL to env vars and returns the map.

func (*DockerEnvPrinter) Print

func (e *DockerEnvPrinter) Print() error

Print retrieves and prints the environment variables for the Docker environment.

type EnvPrinter

type EnvPrinter interface {
	Initialize() error
	Print() error
	GetEnvVars() (map[string]string, error)
	GetAlias() (map[string]string, error)
	PostEnvHook() error
}

EnvPrinter defines the method for printing environment variables.

type KubeEnvPrinter

type KubeEnvPrinter struct {
	BaseEnvPrinter
}

KubeEnvPrinter is a struct that simulates a Kubernetes environment for testing purposes.

func NewKubeEnvPrinter

func NewKubeEnvPrinter(injector di.Injector) *KubeEnvPrinter

NewKubeEnv initializes a new kubeEnv instance using the provided dependency injector.

func (*KubeEnvPrinter) GetEnvVars

func (e *KubeEnvPrinter) GetEnvVars() (map[string]string, error)

GetEnvVars constructs a map of Kubernetes environment variables by setting KUBECONFIG and KUBE_CONFIG_PATH based on the configuration root directory. It checks for a project-specific volume directory and returns current variables if it doesn't exist. If it does, it ensures each PVC directory has a corresponding "PV_" environment variable, returning the map if all are accounted for.

func (*KubeEnvPrinter) Print

func (e *KubeEnvPrinter) Print() error

Print prints the environment variables for the Kube environment.

type MockEnvPrinter

type MockEnvPrinter struct {
	BaseEnvPrinter
	InitializeFunc  func() error
	PrintFunc       func() error
	PostEnvHookFunc func() error
	GetEnvVarsFunc  func() (map[string]string, error)
}

MockEnvPrinter is a struct that simulates an environment for testing purposes.

func NewMockEnvPrinter

func NewMockEnvPrinter() *MockEnvPrinter

NewMockEnvPrinter creates a new instance of MockEnvPrinter.

func (*MockEnvPrinter) GetEnvVars

func (m *MockEnvPrinter) GetEnvVars() (map[string]string, error)

GetEnvVars simulates retrieving environment variables. If a custom GetEnvVarsFunc is provided, it will use that function instead.

func (*MockEnvPrinter) Initialize

func (m *MockEnvPrinter) Initialize() error

Initialize calls the custom InitializeFunc if provided.

func (*MockEnvPrinter) PostEnvHook

func (m *MockEnvPrinter) PostEnvHook() error

PostEnvHook simulates running any necessary commands after the environment variables have been set. If a custom PostEnvHookFunc is provided, it will use that function instead.

func (*MockEnvPrinter) Print

func (m *MockEnvPrinter) Print() error

Print simulates printing the provided environment variables. If a custom PrintFunc is provided, it will use that function instead.

type OmniEnvPrinter

type OmniEnvPrinter struct {
	BaseEnvPrinter
}

OmniEnvPrinter is a struct that simulates a Kubernetes environment for testing purposes.

func NewOmniEnvPrinter

func NewOmniEnvPrinter(injector di.Injector) *OmniEnvPrinter

NewOmniEnv initializes a new omniEnv instance using the provided dependency injector.

func (*OmniEnvPrinter) GetEnvVars

func (e *OmniEnvPrinter) GetEnvVars() (map[string]string, error)

GetEnvVars retrieves the environment variables for the Omni environment.

func (*OmniEnvPrinter) Print

func (e *OmniEnvPrinter) Print() error

Print prints the environment variables for the Omni environment.

type TalosEnvPrinter

type TalosEnvPrinter struct {
	BaseEnvPrinter
}

TalosEnvPrinter is a struct that simulates a Kubernetes environment for testing purposes.

func NewTalosEnvPrinter

func NewTalosEnvPrinter(injector di.Injector) *TalosEnvPrinter

NewTalosEnvPrinter initializes a new talosEnvPrinter instance using the provided dependency injector.

func (*TalosEnvPrinter) GetEnvVars

func (e *TalosEnvPrinter) GetEnvVars() (map[string]string, error)

GetEnvVars retrieves the environment variables for the Talos environment.

func (*TalosEnvPrinter) Print

func (e *TalosEnvPrinter) Print() error

Print prints the environment variables for the Talos environment.

type TerraformEnvPrinter

type TerraformEnvPrinter struct {
	BaseEnvPrinter
}

TerraformEnvPrinter simulates a Terraform environment for testing purposes.

func NewTerraformEnvPrinter

func NewTerraformEnvPrinter(injector di.Injector) *TerraformEnvPrinter

NewTerraformEnvPrinter initializes a new TerraformEnvPrinter instance.

func (*TerraformEnvPrinter) GetEnvVars

func (e *TerraformEnvPrinter) GetEnvVars() (map[string]string, error)

GetEnvVars retrieves environment variables for Terraform by determining the config root and project path, checking for tfvars files, and setting variables based on the OS. It returns a map of environment variables or an error if any step fails.

func (*TerraformEnvPrinter) PostEnvHook

func (e *TerraformEnvPrinter) PostEnvHook() error

PostEnvHook executes operations after setting the environment variables.

func (*TerraformEnvPrinter) Print

func (e *TerraformEnvPrinter) Print() error

Print outputs the environment variables for the Terraform environment.

type WindsorEnvPrinter

type WindsorEnvPrinter struct {
	BaseEnvPrinter
}

WindsorEnvPrinter is a struct that simulates a Kubernetes environment for testing purposes.

func NewWindsorEnvPrinter

func NewWindsorEnvPrinter(injector di.Injector) *WindsorEnvPrinter

NewWindsorEnvPrinter initializes a new WindsorEnvPrinter instance using the provided dependency injector.

func (*WindsorEnvPrinter) GetEnvVars

func (e *WindsorEnvPrinter) GetEnvVars() (map[string]string, error)

GetEnvVars retrieves the environment variables for the Windsor environment.

func (*WindsorEnvPrinter) Print

func (e *WindsorEnvPrinter) Print() error

Print prints the environment variables for the Windsor environment.

Jump to

Keyboard shortcuts

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