kubectl/pkg/cmd
Bryan Boreham 0a152f103a 'kubectl events' command (#99557)
* Basic scaffolding for kubectl events command

* Simple implementation of 'kubectl events'

* Print event fields

Borrowing code from 'kubectl describe'

* Sort events before printing

* Make output more like 'kubectl get events'

Print namespace if fetching from all

* Refactor: extract print functions

To make it easier to add watch function next.

* Implement watch for new events

Run the list function same as before, so those events come out in order,
then watch from the ResourceVersion after the last event.

* Clear up some lint warnings

* Update description and example text

* refactor: introduce a listOptions variable

* Implement --for option

splitResourceTypeName() function borrowed from cli-runtime because we
need similar behaviour to Builder.ResourceNames(), but applying to
Event.InvolvedObject.

* Add kubectl/pkg/cmd/events to vendor/modules.txt

* Add back cmdutil.Factory

Needed in NewCmdAlpha to construct the 'events' command

Signed-off-by: Bryan Boreham <bjboreham@gmail.com>

* Fix lint

Signed-off-by: Bryan Boreham <bjboreham@gmail.com>

* Make package alias go-cromulent

Signed-off-by: Bryan Boreham <bjboreham@gmail.com>

* Use genericclioptions.RESTClientGetter instead of cmdutil.Factory

Signed-off-by: Bryan Boreham <bjboreham@gmail.com>

* Decode object parameter to GroupVersionKind and name

Signed-off-by: Bryan Boreham <bjboreham@gmail.com>

* Merge two files into one

Signed-off-by: Bryan Boreham <bjboreham@gmail.com>

* Include example for --for option

Signed-off-by: Bryan Boreham <bjboreham@gmail.com>

* Fix inconsistent option name in error message

Signed-off-by: Bryan Boreham <bjboreham@gmail.com>

* Remove unnecessary Validate call

Signed-off-by: Bryan Boreham <bjboreham@gmail.com>

* Use fields from event series

Signed-off-by: Bryan Boreham <bjboreham@gmail.com>

* Support chunking of list of events

Signed-off-by: Bryan Boreham <bjboreham@gmail.com>

* Use watchtools utility to receive watch events

Signed-off-by: Bryan Boreham <bjboreham@gmail.com>

* Split struct into flags and options

Flags represents the inputs from the CLI; options are what the running
command needs. This structure parallels the 'wait' command, and should
be easier to write tests for.

Signed-off-by: Bryan Boreham <bjboreham@gmail.com>

* Add some parameters to usage string

Signed-off-by: Bryan Boreham <bjboreham@gmail.com>

* Do only one of list or watch

We tried to print the list first then start a watch after the last
event, but sometimes the server will return "watch is too old" on that
ResourceVersion.
Instead, if we need to watch just start it from the beginning.

Signed-off-by: Bryan Boreham <bjboreham@gmail.com>

* Print message if no events found

Also, if watching, don't print the headings until the first event
arrives.

Signed-off-by: Bryan Boreham <bjboreham@gmail.com>

Kubernetes-commit: a988182f595af64bc007ba9162509e089c36fd89
2021-10-29 17:13:38 +00:00
..
annotate cleanup description on deprecated include-uninitialized flag 2021-07-26 11:14:55 +08:00
apiresources Minor adjustments to descriptions and example text 2021-07-06 15:05:26 -04:00
apply cleanup description on deprecated include-uninitialized flag 2021-07-26 11:14:55 +08:00
attach Minor adjustments to descriptions and example text 2021-07-06 15:05:26 -04:00
auth Provide reference to impersonation options for kubectl auth can-i command. 2021-07-19 21:08:04 -07:00
autoscale Minor adjustments to descriptions and example text 2021-07-06 15:05:26 -04:00
certificates Minor adjustments to descriptions and example text 2021-07-06 15:05:26 -04:00
clusterinfo Minor adjustments to descriptions and example text 2021-07-06 15:05:26 -04:00
completion Adds the PowerShell completion generation (#103758) 2021-08-25 22:29:23 -05:00
config remove Factory that not used 2021-05-17 16:56:12 +08:00
cp Minor adjustments to descriptions and example text 2021-07-06 15:05:26 -04:00
create Improve configmap test 2021-09-03 15:54:11 -04:00
debug Add backwards compatibility for kubectl debug 2021-06-28 18:19:50 +02:00
delete cleanup description on deprecated include-uninitialized flag 2021-07-26 11:14:55 +08:00
describe Fix typo in kubectl describe pods example 2021-08-26 21:00:18 -03:00
diff Add diff command return status code greater than 1 when flags invalid 2021-10-04 13:02:34 +03:00
drain drain node output should say drained not evicted 2021-10-18 11:05:28 -05:00
edit Minor adjustments to descriptions and example text 2021-07-06 15:05:26 -04:00
events 'kubectl events' command (#99557) 2021-10-29 17:13:38 +00:00
exec Minor adjustments to descriptions and example text 2021-07-06 15:05:26 -04:00
explain Minor adjustments to descriptions and example text 2021-07-06 15:05:26 -04:00
expose Minor adjustments to descriptions and example text 2021-07-06 15:05:26 -04:00
get Add completion to the --output/-o flag 2021-10-22 15:15:23 -04:00
help Move pkg/kubectl/cmd/{command} to staging 2019-08-01 11:01:40 -07:00
kustomize Manually update kustomize attachment points. 2021-07-01 17:10:28 -07:00
label cleanup description on deprecated include-uninitialized flag 2021-07-26 11:14:55 +08:00
logs Revert "Add Go tests for custom completions" 2021-05-22 20:47:14 -04:00
options cleanup: use i18n.T on all command descriptions 2020-10-09 13:16:13 +02:00
patch Minor adjustments to descriptions and example text 2021-07-06 15:05:26 -04:00
plugin remove Factory that not used 2021-05-17 16:56:12 +08:00
portforward Minor adjustments to descriptions and example text 2021-07-06 15:05:26 -04:00
proxy Minor adjustments to descriptions and example text 2021-07-06 15:05:26 -04:00
replace Minor adjustments to descriptions and example text 2021-07-06 15:05:26 -04:00
rollout Complete multiple resource names 2021-10-15 15:36:09 -04:00
run Minor improvements in 'kubectl run' flag help 2021-10-06 16:57:47 +02:00
scale Minor adjustments to descriptions and example text 2021-07-06 15:05:26 -04:00
set add unit tests for updateEnv 2021-09-08 10:49:15 +08:00
taint fix: 81134: display conflicted taint without a json representation. 2021-07-29 23:26:07 +00:00
testing generated: Run hack/update-gofmt.sh 2021-08-12 17:13:11 -04:00
top Minor adjustments to descriptions and example text 2021-07-06 15:05:26 -04:00
util Complete multiple resource names 2021-10-15 15:36:09 -04:00
version Fix kubectl version unit test 2021-07-27 11:46:45 -06:00
wait Minor adjustments to descriptions and example text 2021-07-06 15:05:26 -04:00
alpha.go 'kubectl events' command (#99557) 2021-10-29 17:13:38 +00:00
cmd.go 'kubectl events' command (#99557) 2021-10-29 17:13:38 +00:00
cmd_test.go Ignore flags that could precede the Cobra command 2021-09-20 18:20:49 -04:00
profiling.go Move the remaining kubectl bits to k8s.io/kubectl 2020-11-03 22:11:39 +01:00