crit icon indicating copy to clipboard operation
crit copied to clipboard

"crit create token" returns no output

Open seaunderwater opened this issue 3 years ago • 1 comments

When creating a bootstrap token using crit create token, no output is returned to the user:

$ crit create token
$

This is inconvenient for the following reasons:

  • There is no indication that the command was successful.
  • The user is left to search for the token using kubectl get secrets. This becomes difficult when there are several tokens:
$  kg secrets
NAME                                             TYPE                                  DATA   AGE
...
bootstrap-signer-token-dzqwn                     kubernetes.io/service-account-token   3      161m
bootstrap-token-8459vn                           bootstrap.kubernetes.io/token         6      4m10s
bootstrap-token-drwuzf                           bootstrap.kubernetes.io/token         6      2m14s
bootstrap-token-epw5fz                           bootstrap.kubernetes.io/token         6      31m
bootstrap-token-otgi8h                           bootstrap.kubernetes.io/token         6      2m3s
bootstrap-token-pxsarz                           bootstrap.kubernetes.io/token         6      3m2s
bootstrap-token-vygvaf                           bootstrap.kubernetes.io/token         6      2m11s
...
  • The user has to base64 decode and concatenate <token-id>.<token-secret>:
$ kg secret bootstrap-token-8459vn -o yaml 
apiVersion: v1
data:
  auth-extra-groups: c3lzdGVtOmJvb3RzdHJhcHBlcnM6Y3JpdDpkZWZhdWx0LW5vZGUtdG9rZW4=
  expiration: MjAzMC0xMC0wNVQxOTozODo1M1o=
  token-id: ODQ1OXZu
  token-secret: eXE0azkzZHhkd3Zxaml2cQ==
  usage-bootstrap-authentication: dHJ1ZQ==
  usage-bootstrap-signing: dHJ1ZQ==
kind: Secret
...

seaunderwater avatar Oct 07 '20 19:10 seaunderwater

In addition to this, both crit create token and crit generate token specific cobra.MinimumNArgs(1). crit create token should instead specify cobra.MaximumNArgs(1) and crit generate token should specify cobra.NoArgs.

ChrisRx avatar Oct 07 '20 20:10 ChrisRx