-
Notifications
You must be signed in to change notification settings - Fork 40k
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
Implement kubectl annotation update command #11779
Conversation
GCE e2e build/test passed for commit 6bd62938aa05814e7e475867a0278bd1caa6d654. |
Needs rebase |
6bd6293
to
8329e4e
Compare
Code rebased. |
GCE e2e build/test passed for commit 8329e4e97d4fb283f50eb7f26f83282e00398639. |
Thanks! "annotate", a verb, would make a better command name. Please use a "description" annotation as an example. Shell comments start with cc @deads2k @jlowdermilk for code reviews |
} | ||
|
||
// validateNoAnnotationOverwrites validates that when overwrite is false, to-be-updated annotations don't exist in the object annotation map (yet) | ||
func validateNoAnnotationOverwrites(meta *api.ObjectMeta, annotations map[string]string) 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.
It would be more user-friendly to report all the collisions at once instead of having the user fix them one at a time. This could also encourage the user to --overwrite
with the intent of clobbering annotationA, but also end up clobbering annotationB.
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.
Fixed
8329e4e
to
a67a2f1
Compare
GCE e2e build/test passed for commit a67a2f19be0541eda262721cb44279e9e5c9c9af. |
a67a2f1
to
1bbfc8a
Compare
GCE e2e build/test passed for commit 1bbfc8ae2e0234099b9612507c3d52ff939b4232. |
1bbfc8a
to
2c5b56b
Compare
GCE e2e build/test passed for commit 2c5b56bfa81fcfbc356d572a5e2358c18ec3c6df. |
} | ||
|
||
// parseAnnotations retrieves new and remove annotations from annotation args | ||
func parseAnnotations(annotationArgs []string) (newAnnotations map[string]string, removeAnnotations []string) { |
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 could return the error that "validate" would produce during the initial parse: https://github.com/GoogleCloudPlatform/kubernetes/pull/11779/files#diff-051990852b771d2bbf3fcd3209a24063R208
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.
Fixed
2c5b56b
to
f3bf8ed
Compare
GCE e2e build/test passed for commit f3bf8edc4a893a8fb5575baff048b990e1ccacc4. |
# Update pod 'foo' by removing an annotation named 'source_id' if it exists. | ||
# Does not require the --overwrite flag. | ||
$ kubectl annotate pods foo description-` | ||
) |
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.
Hi @janetkuo, I don't quite understand this example. What is the 'source_id' here? Thanks.
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.
It should be 'description'. I changed the example and forgot to change this 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.
Fixed
It seems this command allows the user to add the same annotation key multiple times in a single command, e.g.,
and the end result is we have an annotation a='AAA'. Is this the expected behavior? If so, shall we document it? |
LGTM except a nit and a question. Thank you @janetkuo! |
…e to decouple command framework from business logic.
f3bf8ed
to
7e63213
Compare
limitranges (limits), persistentvolumes (pv), persistentvolumeclaims (pvc), | ||
resourcequotas (quota) or secrets.` | ||
annotate_example = `# Update pod 'foo' with the annotation 'description' and the value 'my frontend'. | ||
# If the same annotation is set multiple times, only the last value will be applied |
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.
@caesarxuchao the behavior you mentioned above is expected. Notify the user about this behavior here.
GCE e2e build/test passed for commit 7e63213. |
LGTM. Thank you! |
@k8s-bot test this [contrib/submit-queue: candidate for merging] |
GCE e2e build/test passed for commit 7e63213. |
Automatic merge from SubmitQueue |
Fixes #11486
cc @bgrant0607