Open nikkictl opened 4 years ago
A few notes after some discussion:
sensuctl describe-type all
, as it contains the more reliable ways to express a resource type https://github.com/sensu/sensu-docs/issues/2692.This is an amazing issue description! Thanks @nikkictl!
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.
The
sensuctl dump
command has had a few iterations in UX since its inception. While more use cases are accounted for and the UX has certainly improved, we still have some inconsistencies with what we consider valid ways to represent a resource type. In this issue, I will provide a brief history of the design, overview of the current behavior, and proposed solution to the problems presented.History
Originally, the command was a wrapper around
sensuctl list
where only short name resource types were supported. For examplesensuctl dump check,entity,role-binding,api-key
would basically runsensuctl check list && sensuctl entity list && sensuctl role-binding list && sensuctl api-key list
. This approach limited users in how expressive they could be to define a resource type, and had other developmental issues such as hard coded resource names.Some improvements to this design included @echlebek's approach to generically and dynamically generate resource types by their fully qualified API names. For example
sensuctl dump core/v2.Check
was equivalent to the short namecheck
and directly correlated to the Go API package. This was especially advantageous to solidifying our resource type system, but while the approach intended to be backwards compatible, it actually introduced unintentional inconsistencies, for example, support for RBAC short names (ex.sensuctl dump checks,entities,rolebindings,apikeys
) on top ofsensuctl
command nouns (ex.sensuctl dump check,entity,role-binding,api-key
).Current Behavior
After some refactors to the types system and resource interfaces,
sensuctl dump
exhibited the following behaviors, which have multiple ways to express a resource type inconsistently across resources.Dump checks
✅
sensuctl dump check
✅sensuctl dump checks
✅sensuctl dump core/v2.Check
Dump entities
✅
sensuctl dump entity
✅sensuctl dump entities
✅sensuctl dump core/v2.Entity
Dump role bindings
❌
sensuctl dump rolebinding
✅sensuctl dump rolebindings
✅sensuctl dump role-binding
✅sensuctl dump role-bindings
✅sensuctl dump core/v2.RoleBinding
Dump api keys
❌
sensuctl dump apikey
✅sensuctl dump apikeys
❌sensuctl dump api-key
❌sensuctl dump api-keys
❌sensuctl dump core/v2.ApiKey
✅sensuctl dump core/v2.APIKey
Dump lifted providers (ex.
secrets/v1.Provider
andauthentication/v2.Provider
) see https://github.com/sensu/sensu-enterprise-go/issues/1216 for more information❌
sensuctl dump secrets/v1.VaultProvider
(accepted arg, but output is incorrect) ❌sensuctl dump secrets/v1.Env
(accepted arg, but output is incorrect) ✅sensuctl dump secrets/v1.Provider
Describe-type only lists fully qualified name and short name (RBAC name)
Expected Behavior
sensuctl describe-type all
)core/v2.Check,core/v2.APIKey
core/v2
resources (RBAC/API name):checks,apikeys
Possible Solution
Implementing stricter validation around acceptable resource type arguments (in
sensuctl dump/prune/describe-type etc
) could be argued as a breaking change. Limiting nouns to the 2 options listed insensuctl describe-type
would ultimately end support for kebab-cased nouns that are supported insensuctl [RESOURCE] list
, such asrole-binding
. However, since kebab-cased nouns are not consistently enforced (ex.sensuctl dump api-key
), it could also be argued that kebab-case only happened to previously work out of coincidence.IMO, we should implement strict enforcements for resource type definitions, otherwise users may end up with unintended results. The logic reuse of resource resolution in
sensuctl prune
makes those assumptions much more dangerous. See https://github.com/sensu/sensu-go/compare/release/6.0...bugfix/sensuctl-dump for POC and https://github.com/sensu/sensu-go/pull/3982 for WIP PR.Steps to Reproduce (for bugs)
sensuctl describe-type all
sensuctl describe-type all
, ex.sensuctl describe-type secrets/v1.VaultProvider
sensuctl dump
commands listed above to observe conflicting behaviorssensuctl [RESOURCE] list
on some of the nouns listed above to observe conflicting behaviorsContext
There has been a lot of general confusion from developers, advocates, and users around the proper noun use in the
sensuctl
CLI. Thesensuctl dump
command is the preferred method of backup/restore for Sensu, therefore resource definitions should be extremely explicit. Thesensuctl prune
command is still considered alpha/experimental, but is a destructive command, and therefore resource definitions should be extremely explicit.Your Environment