sensu / sensu-go

Simple. Scalable. Multi-cloud monitoring.
https://sensu.io
MIT License
1.02k stars 176 forks source link

[sensuctl] Per-resource CRUD action output #3079

Open calebhailey opened 5 years ago

calebhailey commented 5 years ago

Expected Behavior

sensuctl should generate output to indicate what action has been taken on a resource (if any). This output should be consistent across all sensuctl subcommands (e.g. sensuctl create -f foo.yaml and sensuctl check create foo --interactive).

NOTE: this feature is inspired by the Kubernetes kubectl CLI output (for reference).

Examples:

$ sensuctl create -f check_http.yaml
asset "nagios-plugins" created 
check "http-service-health" created 
filter "team-a" unchanged  

...or...

$ sensuctl check create helloworld --interactive
...
...
check "helloworld" modified

The output should follow a consistent syntax of <resource> "<resource_name>" <action> where valid actions are (subject to further specification): "created", "modified", "deleted", or "unchanged".

This output should be especially helpful when processing a resource definition which describes multiple resources via sensuctl create -f, in the event that an invalid resource definition is encountered, the CLI output will help inform the user which action(s) have been taken.

For example, a file named foo.yaml includes definitions for an asset resource, a check resource, and a handler resource, all named "foo" (in that order). The asset and handler definitions are valid, but the check definition is invalid. As sensuctl reads the file and processes the resource definitions sequentially, it would inform the user that the first resource (the asset) was created before encountering an error on the second resource (the check) and exiting without attempting to process the handler definition:

$ sensuctl create -f foo.yaml
asset "foo" created 
ERROR: <error information>

Current Behavior

Inconsistent output from sensuctl across the various subcommands.

Possible Solution

Steps to Reproduce (for bugs)

n/a

Context

It can be difficult to know what actions sensuctl is taking, especially when using sensuctl create -f with a file containing multiple resource definitions.

Your Environment

Sensu Go 5.0.0+

calebhailey commented 4 years ago

Related: https://github.com/sensu/sensu-go/pull/3646

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

ninjaslothx commented 3 years ago

It might be good to have the output optional via a flag. When applying over a larger group of resources stdout can add a bit of overhead to the speed that might not be necessary unless you are debugging or running in a CI job for example.

calebhailey commented 3 years ago

Updated the "possible solution" section of the issue description with the following notes:

NOTE: separate this into two issues: API updates (list item 1), and Sensuctl updates (list items 2-4).

calebhailey commented 3 years ago

Related: https://github.com/sensu/sensu-go/issues/3475

calebhailey commented 3 years ago

Updates: