feat: support SWITCH_CONFIG_PATH env var for config file location#200
Open
posquit0 wants to merge 1 commit into
Open
feat: support SWITCH_CONFIG_PATH env var for config file location#200posquit0 wants to merge 1 commit into
posquit0 wants to merge 1 commit into
Conversation
Add a getDefaultConfigPath() helper that resolves the switch config path from the SWITCH_CONFIG_PATH environment variable, falling back to the existing default of $HOME/.kube/switch-config.yaml when unset. Wire it in as the default value of the --config-path flag across the root, context, gardener and hooks commands. This enables directory-based environment managers such as direnv to select a per-directory kubeswitch configuration without shell aliases or wrapper scripts. The --config-path flag still takes precedence when provided. Closes danielfoehrKn#191
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds support for a
SWITCH_CONFIG_PATHenvironment variable to specify thelocation of the switch configuration file, as an alternative to the
--config-pathflag.A new
getDefaultConfigPath()helper resolves the config path fromSWITCH_CONFIG_PATH(with$HOME/env expansion), falling back to the existingdefault
$HOME/.kube/switch-config.yamlwhen the variable is unset. It is wiredin as the default value of the
--config-pathflag across the root,context,gardener controlplane, andhookscommands. The explicit--config-pathflagstill takes precedence when provided, so behavior is fully backwards compatible.
Why
Closes #191.
This enables directory-based environment managers such as
direnv to select a per-directory kubeswitch
configuration without shell aliases or wrapper scripts — e.g. adding
export SWITCH_CONFIG_PATH=$PWD/switch-config.yamlto a directory's.envrc.Testing
Built locally and verified the resolved
--config-pathdefault:~/.kube/switch-config.yaml(unchanged default)SWITCH_CONFIG_PATH=/custom/path/my-switch.yaml→ used as the defaultSWITCH_CONFIG_PATH='$HOME/projectA/switch.yaml'→$HOMEexpanded correctlyDocs updated in
docs/kubeconfig_stores.md.Security self-check
No new attack surface: the change only reads an environment variable the user
already controls and passes it through the existing
os.ExpandEnvpath used forother paths. No command execution, SQL, or templating is involved. No
SQL-injection / XSS vectors apply to this CLI path-resolution change.