{"modulePath":"github.com/windsorcli/cli","version":"v0.7.1","isLatest":false,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package env\n\n## Variables\n\n```go\nvar WindsorPrefixedVars = []string{\n\t\"WINDSOR_CONTEXT\",\n\t\"WINDSOR_CONTEXT_ID\",\n\t\"WINDSOR_PROJECT_ROOT\",\n\t\"WINDSOR_SESSION_TOKEN\",\n\t\"WINDSOR_MANAGED_ENV\",\n\t\"WINDSOR_MANAGED_ALIAS\",\n}\n```\nWindsorPrefixedVars are the environment variables that are managed by Windsor.\n\n## Types\n\n```go\ntype AwsEnvPrinter struct {\n\tBaseEnvPrinter\n}\n```\nAwsEnvPrinter is a struct that implements AWS environment configuration\n\n```go\nfunc NewAwsEnvPrinter(injector di.Injector) *AwsEnvPrinter\n```\nNewAwsEnvPrinter creates a new AwsEnvPrinter instance\n\n```go\nfunc (e *AwsEnvPrinter) GetEnvVars() (map[string]string, error)\n```\nGetEnvVars retrieves the environment variables for the AWS environment.\n\n```go\nfunc (e *AwsEnvPrinter) Print() error\n```\nPrint prints the environment variables for the AWS environment.\n\n```go\ntype AzureEnvPrinter struct {\n\tBaseEnvPrinter\n}\n```\nAzureEnvPrinter is a struct that implements Azure environment configuration\n\n```go\nfunc NewAzureEnvPrinter(injector di.Injector) *AzureEnvPrinter\n```\nNewAzureEnvPrinter creates a new AzureEnvPrinter instance\n\n```go\nfunc (e *AzureEnvPrinter) GetEnvVars() (map[string]string, error)\n```\nGetEnvVars retrieves the environment variables for the Azure environment.\n\n```go\nfunc (e *AzureEnvPrinter) Print() error\n```\nPrint prints the environment variables for the Azure environment.\n\n```go\ntype BaseEnvPrinter struct {\n\tEnvPrinter\n\t// contains filtered or unexported fields\n}\n```\nBaseEnvPrinter is a base implementation of the EnvPrinter interface\n\n```go\nfunc NewBaseEnvPrinter(injector di.Injector) *BaseEnvPrinter\n```\nNewBaseEnvPrinter creates a new BaseEnvPrinter instance\n\n```go\nfunc (e *BaseEnvPrinter) GetAlias() (map[string]string, error)\n```\nGetAlias is a placeholder for creating an alias for a command.\n\n```go\nfunc (e *BaseEnvPrinter) GetEnvVars() (map[string]string, error)\n```\nGetEnvVars is a placeholder for retrieving environment variables.\n\n```go\nfunc (e *BaseEnvPrinter) GetManagedAlias() []string\n```\nGetManagedAlias returns the shell aliases that are managed by Windsor.\n\n```go\nfunc (e *BaseEnvPrinter) GetManagedEnv() []string\n```\nGetManagedEnv returns the environment variables that are managed by Windsor.\n\n```go\nfunc (e *BaseEnvPrinter) Initialize() error\n```\nInitialize resolves and assigns the shell and configHandler from the injector.\n\n```go\nfunc (e *BaseEnvPrinter) PostEnvHook(directory ...string) error\n```\nPostEnvHook simulates running any necessary commands after the environment variables have been set.\n\n```go\nfunc (e *BaseEnvPrinter) Print(customVars ...map[string]string) error\n```\nPrint outputs the environment variables to the console. If a map of key:value strings is provided, it prints those instead.\n\n```go\nfunc (e *BaseEnvPrinter) PrintAlias(customAlias ...map[string]string) error\n```\nPrintAlias retrieves and prints the shell alias. If a map of key:value strings is provided, it prints those instead.\n\n```go\nfunc (e *BaseEnvPrinter) Reset()\n```\nReset removes all managed environment variables and aliases. It delegates to the shell's Reset method to handle the reset logic.\n\n```go\nfunc (e *BaseEnvPrinter) SetManagedAlias(alias string)\n```\nSetManagedAlias sets the shell aliases that are managed by Windsor.\n\n```go\nfunc (e *BaseEnvPrinter) SetManagedEnv(env string)\n```\nSetManagedEnv sets the environment variables that are managed by Windsor.\n\n```go\ntype DockerEnvPrinter struct {\n\tBaseEnvPrinter\n}\n```\nDockerEnvPrinter is a struct that implements Docker environment configuration\n\n```go\nfunc NewDockerEnvPrinter(injector di.Injector) *DockerEnvPrinter\n```\nNewDockerEnvPrinter creates a new DockerEnvPrinter instance\n\n```go\nfunc (e *DockerEnvPrinter) GetAlias() (map[string]string, error)\n```\nGetAlias 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.\n\n```go\nfunc (e *DockerEnvPrinter) GetEnvVars() (map[string]string, error)\n```\nGetEnvVars 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.\n\n```go\nfunc (e *DockerEnvPrinter) Print() error\n```\nPrint retrieves and prints the environment variables for the Docker environment.\n\n```go\ntype EnvPrinter interface {\n\tInitialize() error\n\tPrint() error\n\tGetEnvVars() (map[string]string, error)\n\tGetAlias() (map[string]string, error)\n\tPostEnvHook(directory ...string) error\n\tGetManagedEnv() []string\n\tGetManagedAlias() []string\n\tSetManagedEnv(env string)\n\tSetManagedAlias(alias string)\n\tReset()\n}\n```\nEnvPrinter defines the method for printing environment variables.\n\n```go\ntype KubeEnvPrinter struct {\n\tBaseEnvPrinter\n}\n```\nKubeEnvPrinter is a struct that implements Kubernetes environment configuration\n\n```go\nfunc NewKubeEnvPrinter(injector di.Injector) *KubeEnvPrinter\n```\nNewKubeEnvPrinter creates a new KubeEnvPrinter instance\n\n```go\nfunc (e *KubeEnvPrinter) GetEnvVars() (map[string]string, error)\n```\nGetEnvVars 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.\n\n```go\nfunc (e *KubeEnvPrinter) Print() error\n```\nPrint prints the environment variables for the Kube environment.\n\n```go\ntype MockEnvPrinter struct {\n\tBaseEnvPrinter\n\tInitializeFunc      func() error\n\tPrintFunc           func() error\n\tPrintAliasFunc      func() error\n\tPostEnvHookFunc     func(directory ...string) error\n\tGetEnvVarsFunc      func() (map[string]string, error)\n\tGetAliasFunc        func() (map[string]string, error)\n\tGetManagedEnvFunc   func() []string\n\tGetManagedAliasFunc func() []string\n\tResetFunc           func()\n}\n```\nMockEnvPrinter is a struct that implements mock environment configuration\n\n```go\nfunc NewMockEnvPrinter() *MockEnvPrinter\n```\nNewMockEnvPrinter creates a new MockEnvPrinter instance\n\n```go\nfunc (m *MockEnvPrinter) GetAlias() (map[string]string, error)\n```\nGetAlias simulates retrieving the shell alias. If a custom GetAliasFunc is provided, it will use that function instead.\n\n```go\nfunc (m *MockEnvPrinter) GetEnvVars() (map[string]string, error)\n```\nGetEnvVars simulates retrieving environment variables. If a custom GetEnvVarsFunc is provided, it will use that function instead.\n\n```go\nfunc (m *MockEnvPrinter) GetManagedAlias() []string\n```\nGetManagedAlias returns the managed aliases. If a custom GetManagedAliasFunc is provided, it will use that function instead.\n\n```go\nfunc (m *MockEnvPrinter) GetManagedEnv() []string\n```\nGetManagedEnv returns the managed environment variables. If a custom GetManagedEnvFunc is provided, it will use that function instead.\n\n```go\nfunc (m *MockEnvPrinter) Initialize() error\n```\nInitialize calls the custom InitializeFunc if provided.\n\n```go\nfunc (m *MockEnvPrinter) PostEnvHook(directory ...string) error\n```\nPostEnvHook simulates running any necessary commands after the environment variables have been set. If a custom PostEnvHookFunc is provided, it will use that function instead.\n\n```go\nfunc (m *MockEnvPrinter) Print() error\n```\nPrint simulates printing the provided environment variables. If a custom PrintFunc is provided, it will use that function instead.\n\n```go\nfunc (m *MockEnvPrinter) PrintAlias() error\n```\nPrintAlias simulates printing the shell aliases. If a custom PrintAliasFunc is provided, it will use that function instead.\n\n```go\nfunc (m *MockEnvPrinter) Reset()\n```\nReset simulates resetting environment variables. If a custom ResetFunc is provided, it will use that function instead.\n\n```go\ntype Shims struct {\n\tStat           func(string) (os.FileInfo, error)\n\tGetwd          func() (string, error)\n\tGlob           func(string) ([]string, error)\n\tWriteFile      func(string, []byte, os.FileMode) error\n\tReadDir        func(string) ([]os.DirEntry, error)\n\tYamlUnmarshal  func([]byte, any) error\n\tYamlMarshal    func(any) ([]byte, error)\n\tJsonUnmarshal  func([]byte, any) error\n\tRemove         func(string) error\n\tRemoveAll      func(string) error\n\tCryptoRandRead func([]byte) (int, error)\n\tGoos           func() string\n\tUserHomeDir    func() (string, error)\n\tMkdirAll       func(string, os.FileMode) error\n\tReadFile       func(string) ([]byte, error)\n\tLookPath       func(string) (string, error)\n\tLookupEnv      func(string) (string, bool)\n\tEnviron        func() []string\n\tGetenv         func(string) string\n}\n```\nShims provides mockable wrappers around system and runtime functions\n\n```go\nfunc NewShims() *Shims\n```\nNewShims creates a new Shims instance with default implementations\n\n```go\ntype TalosEnvPrinter struct {\n\tBaseEnvPrinter\n}\n```\nTalosEnvPrinter manages Talos environment configuration, providing Talos-specific environment variable management and configuration for CLI integration and environment setup.\n\n```go\nfunc NewTalosEnvPrinter(injector di.Injector) *TalosEnvPrinter\n```\nNewTalosEnvPrinter creates and returns a new TalosEnvPrinter instance using the provided injector.\n\n```go\nfunc (e *TalosEnvPrinter) GetEnvVars() (map[string]string, error)\n```\nGetEnvVars 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.\n\n```go\nfunc (e *TalosEnvPrinter) Print() error\n```\nPrint outputs the environment variables for the Talos environment using the embedded BaseEnvPrinter. Returns an error if environment variable retrieval fails or printing fails.\n\n```go\ntype TerraformArgs struct {\n\tModulePath      string\n\tTFDataDir       string\n\tInitArgs        []string\n\tPlanArgs        []string\n\tApplyArgs       []string\n\tRefreshArgs     []string\n\tImportArgs      []string\n\tDestroyArgs     []string\n\tPlanDestroyArgs []string\n\tTerraformVars   map[string]string\n\tBackendConfig   string\n}\n```\nTerraformArgs contains all the arguments needed for terraform operations\n\n```go\ntype TerraformEnvPrinter struct {\n\tBaseEnvPrinter\n\t// contains filtered or unexported fields\n}\n```\nTerraformEnvPrinter is a struct that implements Terraform environment configuration\n\n```go\nfunc NewTerraformEnvPrinter(injector di.Injector) *TerraformEnvPrinter\n```\nNewTerraformEnvPrinter creates a new TerraformEnvPrinter instance\n\n```go\nfunc (e *TerraformEnvPrinter) GenerateTerraformArgs(projectPath, modulePath string) (*TerraformArgs, error)\n```\nGenerateTerraformArgs 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.\n\n```go\nfunc (e *TerraformEnvPrinter) GetEnvVars() (map[string]string, error)\n```\nGetEnvVars 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.\n\n```go\nfunc (e *TerraformEnvPrinter) Initialize() error\n```\nInitialize resolves and assigns dependencies including the blueprint handler from the injector.\n\n```go\nfunc (e *TerraformEnvPrinter) PostEnvHook(directory ...string) error\n```\nPostEnvHook executes operations after setting the environment variables.\n\n```go\nfunc (e *TerraformEnvPrinter) Print() error\n```\nPrint outputs the environment variables for the Terraform environment.\n\n```go\ntype WindsorEnvPrinter struct {\n\tBaseEnvPrinter\n\t// contains filtered or unexported fields\n}\n```\nWindsorEnvPrinter is a struct that implements Windsor environment configuration\n\n```go\nfunc NewWindsorEnvPrinter(injector di.Injector) *WindsorEnvPrinter\n```\nNewWindsorEnvPrinter creates a new WindsorEnvPrinter instance\n\n```go\nfunc (e *WindsorEnvPrinter) GetEnvVars() (map[string]string, error)\n```\nGetEnvVars 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.\n\n```go\nfunc (e *WindsorEnvPrinter) Initialize() error\n```\nInitialize performs dependency injection setup, resolves shell and configuration components, and initializes base functionality. It resolves secrets providers from the dependency injection container and handles environment variable management setup with proper error handling and validation.\n\n```go\nfunc (e *WindsorEnvPrinter) Print() error\n```\nPrint prints the environment variables for the Windsor environment.\n\n","path":"github.com/windsorcli/cli/pkg/env","name":"env","synopsis":"","isRedistributable":true}
