sensu-go
sensu-go copied to clipboard
sensuctl create should give some indication of changes made
Would be great if sensuctl create
gave some indication of resources created/changed, especially if this could be machine parseable (--format yaml
).
Started moving our stack over to sensu go, pretty happy about the /etc/sensu
=> sensuctl create -f
change. However for our config management, it would be really useful to have some indication of what resources were created/changed as a result.
Possible Solution
$ sensuctl create -f spec.yml --format yaml
---
- action: create
type: Handler
name: keepalive
namespace: default
- action: update
type: CheckConfig
name: cpu_usage
namespace: default
Let me know what you think
Thanks for opening this issue @jweede!
Right now, sensuctl create
does what we could call imperative management. In this approach, you tell Sensu API what you want to create/update, not how you want your Sensu cluster to look like. This behavior is simple and easy, but updates to live resources need to be reflected to configuration files, or they will be lost during the next update. This is the equivalent of a PUT
HTTP request.
What you are looking for looks more like declarative management, just like Kubernetes does it with kubectl apply
& kubectl diff
commands. This method retains writes made to live resources and only do whatever is necessary to make it look it what's specified in the resource file. This is the equivalent of a PATCH
HTTP request.
Implementing some sort of declarative management, even just for a diff
command, would require some significant changes around the API and unfortunately this is not something that could just be added to sensuctl create
command. While it's definitely something that could be interesting to have, I feel like there's a significant amount of work required here.
That being said, while I understand it's definitively not as easy, you could always achieve what you are looking for by comparing the resource file with the live resource with a command like this:
$ diff bin/hook.json <(./bin/sensuctl hook info testing --format wrapped-json)
9c9
< "command": "echo hi",
---
> "command": "echo hello",
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.
With the addition of https://github.com/sensu/sensu-go/pull/5016, this request is now possible.