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

set the namespace on the kube client when calling Init #12940

Closed
wants to merge 1 commit into from

Conversation

toneill818
Copy link

closes #8685

What this PR does / why we need it:
When using the Init function for an action.Configuration the passed in namespace is not set on the kube.Client.

Special notes for your reviewer:

If applicable:

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

Signed-off-by: Thomas O'Neill <toneill818@gmail.com>
@pull-request-size pull-request-size bot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Apr 11, 2024
Copy link
Contributor

@robertsirc robertsirc left a comment

Choose a reason for hiding this comment

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

This looks OK to me.

Copy link

@rain-on rain-on left a comment

Choose a reason for hiding this comment

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

LGTM - this is the same fix as in PR#12783 (#12783).

Copy link
Collaborator

@mattfarina mattfarina left a comment

Choose a reason for hiding this comment

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

I'm closing this PR because of the following feedback.

Before I understood how all of this worked, I tried to do this same change. It took a bit of time going down the rabbit hole and building something on top of Helm to understand why I couldn't make this change. The Helm API here is a bit quirky.

@@ -373,6 +373,7 @@ func (cfg *Configuration) recordRelease(r *release.Release) {
func (cfg *Configuration) Init(getter genericclioptions.RESTClientGetter, namespace, helmDriver string, log DebugLog) error {
kc := kube.New(getter)
kc.Log = log
kc.Namespace = namespace
Copy link
Collaborator

Choose a reason for hiding this comment

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

Every so often a pull requests comes in looking to set the namespace here. action.Init is designed to work with the rest of the action package. action.Init can technically be used with multiple Actions without a new instance being created. And, different action runs can have their own namespaces set where Kubernetes resources go. The namespace here is where the Helm secret or configmap is stored instead of where the Kubernetes resources go.

The Install action has an example of how the Namespace is set for Kubernetes resources. For example...

err = resources.Visit(setMetadataVisitor(rel.Name, rel.Namespace, true))

This isn't great for those who want to do something different than what the action package does because of non-exported functions.

We hope to re-design this API at some point. As someone who has built things on top of Helm, I can see where this desire comes from. We are open to bigger changes for Helm v4 and discussing Helm v4.

Until then, this change shouldn't go in because it's going to subtly change behavior for current active users of the Helm SDK.

@mattfarina mattfarina closed this Jun 5, 2024
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.

Go SDK upgrade performing actions in the wrong namespace
4 participants