Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Bash expansion in kubeconfig path of CLI script #63

Merged
merged 2 commits into from
May 8, 2024

Conversation

pizzapim
Copy link
Contributor

@pizzapim pizzapim commented May 7, 2024

Previous change had a regression where $HOME in kubernetes.kubeconfig would be expanded at build-time.
This is because --set KUBECONFIG "${kubeconfig}" (where kubeconfig = "$HOME/.kube/config") would evaluate to --set KUBECONFIG "/home/homeless-shelter/.kube/config" at build-time.

We also cannot do --set KUBECONFIG '${kubeconfig}' because wrapProgram renders this as export KUBECONFIG='$HOME/.kube/config'.
Note the single quotes, which prevents expansion of $HOME.

A solution here is to avoid using --set altogether and use --run with any quotes instead, which allows to expand ~ as well.

@pizzapim pizzapim changed the title Fix $HOME expansion in CLI script Fix Bash expansion in kubeconfig path of CLI script May 7, 2024
pkgs/kubenix.nix Outdated
--set KUBECONFIG "${kubeconfig}" \
--set KUBECTL_EXTERNAL_DIFF "''${DIFF}" \
--set MANIFEST "${result}"
--run 'export KUBECONFIG=${kubeconfig}' \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about this, so user can still overwrite KUBECONFIG at runtime?

Suggested change
--run 'export KUBECONFIG=${kubeconfig}' \
--run 'export KUBECONFIG=''${KUBECONFIG:-${kubeconfig}}' \

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea!

@hall hall merged commit 060f475 into hall:main May 8, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants