Documentation
¶
Index ¶
- Variables
- type AwsEnvPrinter
- type BaseEnvPrinter
- func (e *BaseEnvPrinter) GetAlias() (map[string]string, error)
- func (e *BaseEnvPrinter) GetEnvVars() (map[string]string, error)
- func (e *BaseEnvPrinter) GetManagedAlias() []string
- func (e *BaseEnvPrinter) GetManagedEnv() []string
- func (e *BaseEnvPrinter) Initialize() error
- func (e *BaseEnvPrinter) PostEnvHook() error
- func (e *BaseEnvPrinter) Print(customVars ...map[string]string) error
- func (e *BaseEnvPrinter) PrintAlias(customAlias ...map[string]string) error
- func (e *BaseEnvPrinter) Reset()
- func (e *BaseEnvPrinter) SetManagedAlias(alias string)
- func (e *BaseEnvPrinter) SetManagedEnv(env string)
- type DockerEnvPrinter
- type EnvPrinter
- type KubeEnvPrinter
- type MockEnvPrinter
- func (m *MockEnvPrinter) GetAlias() (map[string]string, error)
- func (m *MockEnvPrinter) GetEnvVars() (map[string]string, error)
- func (m *MockEnvPrinter) GetManagedAlias() []string
- func (m *MockEnvPrinter) GetManagedEnv() []string
- func (m *MockEnvPrinter) Initialize() error
- func (m *MockEnvPrinter) PostEnvHook() error
- func (m *MockEnvPrinter) Print() error
- func (m *MockEnvPrinter) PrintAlias() error
- func (m *MockEnvPrinter) Reset()
- type OmniEnvPrinter
- type Shims
- type TalosEnvPrinter
- type TerraformEnvPrinter
- type WindsorEnvPrinter
Constants ¶
This section is empty.
Variables ¶
var WindsorPrefixedVars = []string{
"WINDSOR_CONTEXT",
"WINDSOR_PROJECT_ROOT",
"WINDSOR_SESSION_TOKEN",
"WINDSOR_MANAGED_ENV",
"WINDSOR_MANAGED_ALIAS",
}
WindsorPrefixedVars are the environment variables that are managed by Windsor.
Functions ¶
This section is empty.
Types ¶
type AwsEnvPrinter ¶
type AwsEnvPrinter struct {
BaseEnvPrinter
}
AwsEnvPrinter is a struct that implements AWS environment configuration
func NewAwsEnvPrinter ¶
func NewAwsEnvPrinter(injector di.Injector) *AwsEnvPrinter
NewAwsEnvPrinter creates a new AwsEnvPrinter instance
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 {
EnvPrinter
// contains filtered or unexported fields
}
BaseEnvPrinter is a base implementation of 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) GetManagedAlias ¶ added in v0.5.6
func (e *BaseEnvPrinter) GetManagedAlias() []string
GetManagedAlias returns the shell aliases that are managed by Windsor.
func (*BaseEnvPrinter) GetManagedEnv ¶ added in v0.5.6
func (e *BaseEnvPrinter) GetManagedEnv() []string
GetManagedEnv returns the environment variables that are managed by Windsor.
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.
func (*BaseEnvPrinter) PrintAlias ¶ added in v0.5.6
func (e *BaseEnvPrinter) PrintAlias(customAlias ...map[string]string) error
PrintAlias retrieves and prints the shell alias. If a map of key:value strings is provided, it prints those instead.
func (*BaseEnvPrinter) Reset ¶ added in v0.5.6
func (e *BaseEnvPrinter) Reset()
Reset removes all managed environment variables and aliases. It delegates to the shell's Reset method to handle the reset logic.
func (*BaseEnvPrinter) SetManagedAlias ¶ added in v0.5.6
func (e *BaseEnvPrinter) SetManagedAlias(alias string)
SetManagedAlias sets the shell aliases that are managed by Windsor.
func (*BaseEnvPrinter) SetManagedEnv ¶ added in v0.5.6
func (e *BaseEnvPrinter) SetManagedEnv(env string)
SetManagedEnv sets the environment variables that are managed by Windsor.
type DockerEnvPrinter ¶
type DockerEnvPrinter struct {
BaseEnvPrinter
}
DockerEnvPrinter is a struct that implements Docker environment configuration
func NewDockerEnvPrinter ¶
func NewDockerEnvPrinter(injector di.Injector) *DockerEnvPrinter
NewDockerEnvPrinter creates a new DockerEnvPrinter instance
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 sets Docker-specific env vars, using DOCKER_HOST from vm.driver config or existing env. Defaults to WINDSORCONFIG or home dir for Docker paths, ensuring config directory exists. Writes config if content changes, adds DOCKER_CONFIG and REGISTRY_URL, and returns the map. Handles "colima", "docker-desktop", and "docker" vm.driver settings, defaulting to "default" if unrecognized.
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
GetManagedEnv() []string
GetManagedAlias() []string
SetManagedEnv(env string)
SetManagedAlias(alias string)
Reset()
}
EnvPrinter defines the method for printing environment variables.
type KubeEnvPrinter ¶
type KubeEnvPrinter struct {
BaseEnvPrinter
}
KubeEnvPrinter is a struct that implements Kubernetes environment configuration
func NewKubeEnvPrinter ¶
func NewKubeEnvPrinter(injector di.Injector) *KubeEnvPrinter
NewKubeEnvPrinter creates a new KubeEnvPrinter instance
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
PrintAliasFunc func() error
PostEnvHookFunc func() error
GetEnvVarsFunc func() (map[string]string, error)
GetAliasFunc func() (map[string]string, error)
GetManagedEnvFunc func() []string
GetManagedAliasFunc func() []string
ResetFunc func()
}
MockEnvPrinter is a struct that implements mock environment configuration
func NewMockEnvPrinter ¶
func NewMockEnvPrinter() *MockEnvPrinter
NewMockEnvPrinter creates a new MockEnvPrinter instance
func (*MockEnvPrinter) GetAlias ¶ added in v0.5.6
func (m *MockEnvPrinter) GetAlias() (map[string]string, error)
GetAlias simulates retrieving the shell alias. If a custom GetAliasFunc is provided, it will use that function instead.
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) GetManagedAlias ¶ added in v0.5.7
func (m *MockEnvPrinter) GetManagedAlias() []string
GetManagedAlias returns the managed aliases. If a custom GetManagedAliasFunc is provided, it will use that function instead.
func (*MockEnvPrinter) GetManagedEnv ¶ added in v0.5.7
func (m *MockEnvPrinter) GetManagedEnv() []string
GetManagedEnv returns the managed environment variables. If a custom GetManagedEnvFunc 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.
func (*MockEnvPrinter) PrintAlias ¶ added in v0.5.6
func (m *MockEnvPrinter) PrintAlias() error
PrintAlias simulates printing the shell aliases. If a custom PrintAliasFunc is provided, it will use that function instead.
func (*MockEnvPrinter) Reset ¶ added in v0.5.6
func (m *MockEnvPrinter) Reset()
Reset simulates resetting environment variables. If a custom ResetFunc is provided, it will use that function instead.
type OmniEnvPrinter ¶
type OmniEnvPrinter struct {
BaseEnvPrinter
}
OmniEnvPrinter is a struct that implements Omni environment configuration
func NewOmniEnvPrinter ¶
func NewOmniEnvPrinter(injector di.Injector) *OmniEnvPrinter
NewOmniEnvPrinter creates a new OmniEnvPrinter instance
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 Shims ¶ added in v0.5.7
type Shims struct {
Stat func(string) (os.FileInfo, error)
Getwd func() (string, error)
Glob func(string) ([]string, error)
WriteFile func(string, []byte, os.FileMode) error
ReadDir func(string) ([]os.DirEntry, error)
YamlUnmarshal func([]byte, interface{}) error
YamlMarshal func(interface{}) ([]byte, error)
Remove func(string) error
RemoveAll func(string) error
CryptoRandRead func([]byte) (int, error)
Goos func() string
UserHomeDir func() (string, error)
MkdirAll func(string, os.FileMode) error
ReadFile func(string) ([]byte, error)
LookPath func(string) (string, error)
LookupEnv func(string) (string, bool)
Environ func() []string
Getenv func(string) string
}
Shims provides mockable wrappers around system and runtime functions
type TalosEnvPrinter ¶
type TalosEnvPrinter struct {
BaseEnvPrinter
}
TalosEnvPrinter is a struct that implements Talos environment configuration
func NewTalosEnvPrinter ¶
func NewTalosEnvPrinter(injector di.Injector) *TalosEnvPrinter
NewTalosEnvPrinter creates a new TalosEnvPrinter instance
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 is a struct that implements Terraform environment configuration
func NewTerraformEnvPrinter ¶
func NewTerraformEnvPrinter(injector di.Injector) *TerraformEnvPrinter
NewTerraformEnvPrinter creates a new TerraformEnvPrinter instance
func (*TerraformEnvPrinter) GetEnvVars ¶
func (e *TerraformEnvPrinter) GetEnvVars() (map[string]string, error)
GetEnvVars retrieves environment variables for Terraform. It determines the config root and project path, checks for tfvars files, and sets variables based on the OS. If not in a terraform project folder, it resets all TF_ vars that are already set in the environment. 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
// contains filtered or unexported fields
}
WindsorEnvPrinter is a struct that implements Windsor environment configuration
func NewWindsorEnvPrinter ¶
func NewWindsorEnvPrinter(injector di.Injector) *WindsorEnvPrinter
NewWindsorEnvPrinter creates a new WindsorEnvPrinter instance
func (*WindsorEnvPrinter) GetEnvVars ¶
func (e *WindsorEnvPrinter) GetEnvVars() (map[string]string, error)
GetEnvVars constructs a map of Windsor-specific environment variables by retrieving the current context, project root, and session token. It resolves secrets in custom environment variables using configured providers, handles caching of values, and manages environment variables and aliases. For secrets, it leverages the secrets cache to avoid unnecessary decryption while ensuring variables are properly tracked in the managed environment list. Windsor-prefixed variables are automatically included in the final environment setup to provide a comprehensive configuration.
func (*WindsorEnvPrinter) Initialize ¶ added in v0.5.6
func (e *WindsorEnvPrinter) Initialize() error
Initialize sets up the WindsorEnvPrinter, including resolving secrets providers.
func (*WindsorEnvPrinter) Print ¶
func (e *WindsorEnvPrinter) Print() error
Print prints the environment variables for the Windsor environment.