-
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
Include event type in kubectl get -w
output
#72416
Conversation
/retest |
57b7fcd
to
8b0da1e
Compare
kubectl get -w
outputkubectl get -w
output
8b0da1e
to
f866f3c
Compare
/retest |
staging/src/k8s.io/cli-runtime/pkg/genericclioptions/printers/json.go
Outdated
Show resolved
Hide resolved
@@ -42,6 +43,11 @@ type NamePrinter struct { | |||
// PrintObj is an implementation of ResourcePrinter.PrintObj which decodes the object | |||
// and print "resource/name" pair. If the object is a List, print all items in it. | |||
func (p *NamePrinter) PrintObj(obj runtime.Object, w io.Writer) error { | |||
switch castObj := obj.(type) { | |||
case *metav1.WatchEvent: |
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 wish we'd done a watch event interface. I can take that as a future cleanup.
4ecb0b1
to
313ffbd
Compare
kubectl get -w
outputkubectl get -w
output
/priority important-longterm |
313ffbd
to
e3139c4
Compare
addressed comments, rebased on #79530 |
e3139c4
to
fc6730a
Compare
fc6730a
to
1327346
Compare
@@ -171,6 +173,7 @@ func NewCmdGet(parent string, f cmdutil.Factory, streams genericclioptions.IOStr | |||
cmd.Flags().StringVar(&o.Raw, "raw", o.Raw, "Raw URI to request from the server. Uses the transport specified by the kubeconfig file.") | |||
cmd.Flags().BoolVarP(&o.Watch, "watch", "w", o.Watch, "After listing/getting the requested object, watch for changes. Uninitialized objects are excluded if no object name is provided.") | |||
cmd.Flags().BoolVar(&o.WatchOnly, "watch-only", o.WatchOnly, "Watch for changes to the requested object(s), without listing/getting first.") | |||
cmd.Flags().BoolVar(&o.OutputWatchEvents, "output-watch-events", o.OutputWatchEvents, "Output watch event objects when --watch or --watch-only is used. Existing objects are output as initial ADDED 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.
Maybe this should be --watch-events
or --include-events
(although I could maybe see that being confused with Events). We're not super strict about prefixing flags though.
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 like --output-...
as a prefix, and since it's only allowed with --watch
(or --watch-only
), I thought qualifying it would be clearer
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.
--include-events
sounds like what describe does, separately fetching/printing related events
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: liggitt, smarterclayton 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 |
What type of PR is this?
/kind feature
What this PR does / why we need it:
Allows the type of event (ADDED, MODIFIED, DELETED) to be seen when watching objects with
kubectl get -w --output-watch-events
Before:
After:
Which issue(s) this PR fixes:
Fixes kubernetes/kubectl#185
Based on #79530
Does this PR introduce a user-facing change?:
/cc @smarterclayton @seans3
/sig cli