Documentation
¶
Index ¶
- Variables
- type AwsEnvPrinter
- type AzureEnvPrinter
- 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) PostEnvHook(directory ...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) PostEnvHook(directory ...string) error
- func (m *MockEnvPrinter) Print() error
- func (m *MockEnvPrinter) PrintAlias() error
- func (m *MockEnvPrinter) Reset()
- type Shims
- type TalosEnvPrinter
- type TerraformArgs
- type TerraformEnvPrinter
- type WindsorEnvPrinter
Constants ¶
This section is empty.
Variables ¶
var WindsorPrefixedVars = []string{
"WINDSOR_CONTEXT",
"WINDSOR_CONTEXT_ID",
"BUILD_ID",
"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(shell shell.Shell, configHandler config.ConfigHandler) *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.
type AzureEnvPrinter ¶
type AzureEnvPrinter struct {
BaseEnvPrinter
}
AzureEnvPrinter is a struct that implements Azure environment configuration
func NewAzureEnvPrinter ¶
func NewAzureEnvPrinter(shell shell.Shell, configHandler config.ConfigHandler) *AzureEnvPrinter
NewAzureEnvPrinter creates a new AzureEnvPrinter instance
func (*AzureEnvPrinter) GetEnvVars ¶
func (e *AzureEnvPrinter) GetEnvVars() (map[string]string, error)
GetEnvVars retrieves the environment variables for the Azure 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(shell shell.Shell, configHandler config.ConfigHandler) *BaseEnvPrinter
NewBaseEnvPrinter creates a new BaseEnvPrinter instance
func (*BaseEnvPrinter) GetAlias ¶
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 ¶
func (e *BaseEnvPrinter) GetManagedAlias() []string
GetManagedAlias returns the shell aliases that are managed by Windsor.
func (*BaseEnvPrinter) GetManagedEnv ¶
func (e *BaseEnvPrinter) GetManagedEnv() []string
GetManagedEnv returns the environment variables that are managed by Windsor.
func (*BaseEnvPrinter) PostEnvHook ¶
func (e *BaseEnvPrinter) PostEnvHook(directory ...string) error
PostEnvHook simulates running any necessary commands after the environment variables have been set.
func (*BaseEnvPrinter) Reset ¶
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 ¶
func (e *BaseEnvPrinter) SetManagedAlias(alias string)
SetManagedAlias sets the shell aliases that are managed by Windsor.
func (*BaseEnvPrinter) SetManagedEnv ¶
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(shell shell.Shell, configHandler config.ConfigHandler) *DockerEnvPrinter
NewDockerEnvPrinter creates a new DockerEnvPrinter instance
func (*DockerEnvPrinter) GetAlias ¶
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.
type EnvPrinter ¶
type EnvPrinter interface {
GetEnvVars() (map[string]string, error)
GetAlias() (map[string]string, error)
PostEnvHook(directory ...string) 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(shell shell.Shell, configHandler config.ConfigHandler) *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. If not all volumes are accounted for, it attempts to query the Kubernetes API to create environment variables for matching PVCs. If the API is unavailable, it gracefully degrades by returning the basic environment variables without failing.
type MockEnvPrinter ¶
type MockEnvPrinter struct {
BaseEnvPrinter
PrintFunc func() error
PrintAliasFunc func() error
PostEnvHookFunc func(directory ...string) 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 ¶
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 ¶
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 ¶
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) PostEnvHook ¶
func (m *MockEnvPrinter) PostEnvHook(directory ...string) 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 ¶
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 ¶
func (m *MockEnvPrinter) Reset()
Reset simulates resetting environment variables. If a custom ResetFunc is provided, it will use that function instead.
type Shims ¶
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, any) error
YamlMarshal func(any) ([]byte, error)
JsonUnmarshal func([]byte, any) 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 manages Talos environment configuration, providing Talos-specific environment variable management and configuration for CLI integration and environment setup.
func NewTalosEnvPrinter ¶
func NewTalosEnvPrinter(shell shell.Shell, configHandler config.ConfigHandler) *TalosEnvPrinter
NewTalosEnvPrinter creates and returns a new TalosEnvPrinter instance.
func (*TalosEnvPrinter) GetEnvVars ¶
func (e *TalosEnvPrinter) GetEnvVars() (map[string]string, error)
GetEnvVars returns a map of environment variables for the Talos environment. It sets the TALOSCONFIG variable and, if the cluster driver is "omni", also sets OMNICONFIG. Returns an error if the configuration root cannot be determined.
type TerraformArgs ¶
type TerraformArgs struct {
ModulePath string
TFDataDir string
InitArgs []string
PlanArgs []string
ApplyArgs []string
RefreshArgs []string
ImportArgs []string
DestroyArgs []string
PlanDestroyArgs []string
TerraformVars map[string]string
BackendConfig string
}
TerraformArgs contains all the arguments needed for terraform operations
type TerraformEnvPrinter ¶
type TerraformEnvPrinter struct {
BaseEnvPrinter
}
TerraformEnvPrinter is a struct that implements Terraform environment configuration
func NewTerraformEnvPrinter ¶
func NewTerraformEnvPrinter(shell shell.Shell, configHandler config.ConfigHandler) *TerraformEnvPrinter
NewTerraformEnvPrinter creates a new TerraformEnvPrinter instance
func (*TerraformEnvPrinter) GenerateTerraformArgs ¶
func (e *TerraformEnvPrinter) GenerateTerraformArgs(projectPath, modulePath string) (*TerraformArgs, error)
GenerateTerraformArgs constructs Terraform CLI arguments and environment variables for given project and module paths. Resolves config root, locates tfvars files, generates backend config args, and assembles all CLI/env values needed for Terraform operations. Returns a TerraformArgs struct or error.
func (*TerraformEnvPrinter) GetEnvVars ¶
func (e *TerraformEnvPrinter) GetEnvVars() (map[string]string, error)
GetEnvVars returns a map of environment variables for Terraform operations. If not in a Terraform project directory, it unsets managed TF_ variables present in the environment. Otherwise, it generates Terraform arguments and augments them with dependency variables. Returns the environment variable map or an error if resolution fails.
func (*TerraformEnvPrinter) PostEnvHook ¶
func (e *TerraformEnvPrinter) PostEnvHook(directory ...string) error
PostEnvHook executes operations after setting the environment variables.
type WindsorEnvPrinter ¶
type WindsorEnvPrinter struct {
BaseEnvPrinter
// contains filtered or unexported fields
}
WindsorEnvPrinter is a struct that implements Windsor environment configuration
func NewWindsorEnvPrinter ¶
func NewWindsorEnvPrinter(shell shell.Shell, configHandler config.ConfigHandler, secretsProviders []secrets.SecretsProvider, allEnvPrinters []EnvPrinter) *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.