-
Notifications
You must be signed in to change notification settings - Fork 39.7k
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
Introduce events flag for describers #24554
Introduce events flag for describers #24554
Conversation
@@ -53,7 +53,13 @@ import ( | |||
// if the output could not be generated. Implementers typically | |||
// abstract the retrieval of the named object from a remote server. | |||
type Describer interface { | |||
Describe(namespace, name string) (output string, err error) | |||
Describe(namespace, name string, describerSetting *DescriberSetting) (output string, err 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.
Is there any reason for describerSetting
to be a pointer?
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.
At this point, no. Later, DescriberSetting could contain non-pointer variables you would not want to copy.
Any reason for it not to be a pointer?
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.
We avoid pointers in apis unless the absense of a value (nil) is something we care about.
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.
Ok, will update the PR.
There are three objects that has no unit-tests at all: |
824d311
to
7120cd7
Compare
cc @kubernetes/rh-cluster-infra @kubernetes/kubectl @kubernetes/rh-ux |
|
||
// DescriberSetting holds display configuration for each object | ||
// describer to control what is printed. | ||
type DescriberSetting struct { |
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 this should be pluralized - DescriberSettings. Or maybe DescriberOptions.
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 though setting is uncountable till this moment. Looks like google says "use plural if there are more things to set". DescriberConfig
would work too. If the describer is meant just to "render", rendering settings is quite common. I like this comment [1]. DescriberPreferences
is the closest to the behaviour from the point of the describer. On the other hand DescriberOptions
makes more sense from the point of the kubectl describe
command as events=true
is by default and changing to false is providing option to change it.
DescribeOptions
is already used so DescriberOptions
counts out. Let's use DescriberSettings
if noone against :).
Need to run Could you also please add some tests to |
@ncdc, yeah, I run that command at the end of our standup and blew my computer away. Sometimes the go compiler just eats all my memory. Was thinking about |
74f9146
to
5ac2705
Compare
Create separate issues for each one? |
cc @janetkuo |
You will need to add the flag here: |
@@ -93,11 +94,12 @@ func NewCmdDescribe(f *cmdutil.Factory, out io.Writer) *cobra.Command { | |||
kubectl.AddJsonFilenameFlag(cmd, &options.Filenames, usage) | |||
cmdutil.AddRecursiveFlag(cmd, &options.Recursive) | |||
cmd.Flags().StringP("selector", "l", "", "Selector (label query) to filter on") | |||
cmd.Flags().BoolVar(&describerSettings.ShowEvents, "events", true, "If true, display also object events.") |
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 prefer we call the flag show-events
, we use that convention already with the show-all
flag, and it parallels the name in the describer settings.
I would update the text to be If true, display events related to the described object.
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.
👍
dad88b7
to
712eeca
Compare
712eeca
to
dabee4d
Compare
}, | ||
}, events), | ||
}, | ||
//"HorizontalPodAutoscalerDescriber": &HorizontalPodAutoscalerDescriber{ |
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.
Did you mean to comment this out?
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 have changed all the three describers into TODO note. Opened separate issue for them [1].
[1] #24731
3a78128
to
a595332
Compare
/me has no idea what the bot did in #24554 (comment) |
Looks good, but please squash commits. |
be01d0b
to
a6a4b1d
Compare
New |
Introduce DescriberSettings for Describer display options Introduce --show-events flag and DescriberSettings in Describer methods Introduce unit-tests Regenerated kubectl describe docs Add events flag tests to test-cmd.sh Signed-off-by: [email protected] Signed-off-by: [email protected]
a6a4b1d
to
dd2c9c5
Compare
@ncdc @eparis @jlowdermilk can you reset |
LGTM |
GCE e2e build/test passed for commit dd2c9c5. |
@k8s-bot test this [submit-queue is verifying that this PR is safe to merge] |
GCE e2e build/test passed for commit dd2c9c5. |
Automatic merge from submit-queue |
Printing events for a given object is not always needed. Thus, introducing --show-events=false to
kubectl describe
to skip events printing.Fixes: #24239