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

Allow setting namespace in helm template without a kubeconfig #12126

Conversation

alex-hunt-materialize
Copy link

What this PR does / why we need it:

If you don't have a working kubeconfig, helm template does not respect the --namespace option, instead silently ignoring it and using "default". It gets set on the settings object, but does not get returned by the Namespace() method. helm template should not require a working kubeconfig or any communication with a kubernetes cluster, as it is only generating templates.

This PR adds a fallback to return the already set namespace field, rather than ignoring the user's intentions and returning "default".

Closes #12124

Special notes for your reviewer:

If applicable:

  • this PR contains documentation
  • this PR contains unit tests
  • this PR has been tested for backwards compatibility

If you don't have a working kubeconfig, `helm template` does not respect
the `--namespace` option. It gets set on the settings object, but does
not get returned. `helm template` should not require a working
kubeconfig or any communication with a kubernetes cluster.

Signed-off-by: Alex Hunt <alex.hunt@materialize.com>
@pull-request-size pull-request-size bot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Jun 8, 2023
Copy link
Contributor

@joejulian joejulian left a comment

Choose a reason for hiding this comment

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

After giving this some thought, this seems correct. There is another flag in this struct that overrides the environment variable.

env.Debug, _ = strconv.ParseBool(os.Getenv("HELM_DEBUG"))

We can't do namespace the same way, though, because the kubeconfig flags will need parsed to get the default namespace from the kubeconfig (if set and env is not). This seems like the appropriate place to process this override.

I would like to see this added to the unit test though.

@CalvinKrist
Copy link
Contributor

@joejulian I copied their fix and added a unit test here #12979. I confirmed that without the fix being present the test fails.

@joejulian joejulian closed this Apr 29, 2024
@alex-hunt-materialize alex-hunt-materialize deleted the template_namespace_without_kubeconfig branch April 29, 2024 14:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

helm template inconsistently respects the --namespace option in different environments
3 participants