-
Notifications
You must be signed in to change notification settings - Fork 38.9k
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
Strip .meta.managedFields for kubectl edit command #91946
Conversation
This field is editable and we shouldn't make that impossible. Can we get a flag for not stripping it? |
@@ -437,6 +439,22 @@ func (o *EditOptions) Run() error { | |||
} | |||
} | |||
|
|||
func stripManagedFields(obj runtime.Object) 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.
I think technically this should work, however I am not sure it is future proof if we e.g. add another field format. I would greatly prefer it if you put them back before constructing the patch that will be sent to apiserver.
6729ecf
to
2774e92
Compare
2774e92
to
a2c6660
Compare
/retest |
if err != nil { | ||
return err | ||
} | ||
mf := o.managedFields[metaObjs.GetUID()] |
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 recommend detecting if the user tried to add something here and failing with a message if so, e.g. "you can't use kubectl edit
to edit the managed field list".
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.
Yeah, there's a mergepatch.PreconditionFunc
which I wanted to update and I forgot, updated.
@@ -437,6 +454,49 @@ func (o *EditOptions) Run() error { | |||
} | |||
} | |||
|
|||
func (o *EditOptions) extractManagedFields(obj runtime.Object) 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.
A test for extract / clear / restore would be good?
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.
Done
return metaObjs.GetUID(), mf, nil | ||
} | ||
|
||
func (o *EditOptions) reAddManagedFields(infos []*resource.Info) 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.
nit: I suggest "restore" rather than "reAdd"
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.
Done
a2c6660
to
86d2481
Compare
This looks to me like it does the right thing now. 👍 Maybe you want an official LGTM from someone a bit closer to the kubectl code though? |
This PR may require API review. If so, when the changes are ready, complete the pre-review checklist and request an API review. Status of requested reviews is tracked in the API Review project. |
/lgtm |
/retest Review the full test history for this PR. Silence the bot with an |
2 similar comments
/retest Review the full test history for this PR. Silence the bot with an |
/retest Review the full test history for this PR. Silence the bot with an |
/hold |
c29c895
to
9e5c533
Compare
/hold cancel |
/lgtm |
/milestone v1.19 |
/retest |
1 similar comment
/retest |
/retest Review the full test history for this PR. Silence the bot with an |
What type of PR is this?
/kind feature
/sig cli
/priority backlog
What this PR does / why we need it:
With the introduction of
.meta.managedFields
it's cumbersome to edit any resource due to the size of that additional fields. This PR hides those fields, since they should not even be modified by consumers directly.Which issue(s) this PR fixes:
Fixes #90066
Special notes for your reviewer:
/assign @sttts @apelisse
Does this PR introduce a user-facing change?: