- Notifications
You must be signed in to change notification settings - Fork 42k
Introduce kuberc view/set commands under kubectl alpha #135003
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
Conversation
| /triage accepted |
| /hold |
87f2309 to e6223d8 Compare | /retest |
soltysh left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great - thank you! But I left a bunch of comments 😅
| } | ||
| | ||
| var pref v1beta1.Preference | ||
| if err := yaml.Unmarshal(data, &pref); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same argument about decoding prefs.
| return fmt.Errorf("kuberc file not found at %s", o.KubeRCFile) | ||
| } | ||
| return fmt.Errorf("error reading kuberc file: %w", err) | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe we've agreed that when running kubectl kuberc view w/o any flags, so for the default location ($HOME/.kube/kuberc) and with the file NOT existing, we would create the default one for the user. No?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've updated the code to generate a recommended preference file by first prompting to the user. Please let me know your thoughts about the mechanism and flow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great! One suggestion I have is to create a DefaultPreferences function, again in staging/src/k8s.io/kubectl/pkg/kuberc/ directory and just re-use it here. This way we'll have all of kuberc management in a single spot. This way when promoting to GA we'll update all of those helpers to always produce the latest version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
396d67a to a99628e Compare | explicitly = true | ||
| } | ||
| | ||
| if kubeRCFile == "" && os.Getenv("KUBERC") != "" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to be the bug. kubeRCFile can't be empty.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch 😅
| /retest |
| unrelated |
soltysh left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few comments, mostly non-blocking. Let's sync on slack, if you're able to pick them up before the freeze.
| } | ||
| | ||
| // SavePreference saves the preference to the kuberc file | ||
| func SavePreference(pref *v1beta1.Preference, file string, out io.Writer) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For some time in the future, I think we would want all kuberc management function inside staging/src/k8s.io/kubectl/pkg/kuberc/ directory. We already have there marshal.go so saving that file would be a natural place as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file has been moved under pkg/kuberc.
| explicitly = true | ||
| } | ||
| | ||
| if kubeRCFile == "" && os.Getenv("KUBERC") != "" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch 😅
| return fmt.Errorf("kuberc file not found at %s", o.KubeRCFile) | ||
| } | ||
| return fmt.Errorf("error reading kuberc file: %w", err) | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great! One suggestion I have is to create a DefaultPreferences function, again in staging/src/k8s.io/kubectl/pkg/kuberc/ directory and just re-use it here. This way we'll have all of kuberc management in a single spot. This way when promoting to GA we'll update all of those helpers to always produce the latest version.
| } | ||
| | ||
| var pref *v1beta1.Preference | ||
| if err := yaml.Unmarshal(data, &pref); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's odd, I'll look into it, so let's leave it for a followup.
| }, | ||
| } | ||
| | ||
| cmd.Flags().StringVar(&o.KubeRCFile, "file", o.KubeRCFile, "Path to the kuberc file to modify. If it is not specified, default kuberc location will be used.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it should not matter, we should use only one flag for consistency. If you look into what we're doing in kubectl config commands, all of them rely on the built-in --kubeconfig flag. So introducing a different name here, would be confusing.
| /retest |
| /label tide/merge-method-squash |
soltysh left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
/approve
| LGTM label has been added. Git tree hash: 1b10d35cf414d1093812d1246e9f6e1ab388659a |
| /hold cancel |
| [APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: ardaguclu, soltysh The full list of commands accepted by this bot can be found here. The pull request process is described here Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
…5003) * Introduce kuberc view/set commands under kubectl alpha * Apply requested changes * Apply requested changes
What type of PR is this?
/kind feature
What this PR does / why we need it:
This PR introduces two commands under kubectl alpha for kuberc file operations.
--kubercorKUBERCenv var or default location).--file).Which issue(s) this PR is related to:
KEP: kubernetes/enhancements#3104
Does this PR introduce a user-facing change?
Special notes for your reviewer:
Claude helped me preparation of this PR (but this is not a bulk generated PR).
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: