Skip to content

Commit

Permalink
Update help message for add token command and allow token removal f…
Browse files Browse the repository at this point in the history
…rom the `rm` command. (#12118) (#12439)

* Update tokens add messaging to outline that it can be a list of tokens.

* Allow deleting tokens with rm.
  • Loading branch information
hatched authored May 5, 2022
1 parent 1bcd6e0 commit 5dadc57
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions tool/tctl/common/resource_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,11 @@ func (rc *ResourceCommand) Delete(client auth.ClientI) (err error) {
return trace.Wrap(err)
}
fmt.Printf("role %q has been deleted\n", rc.ref.Name)
case types.KindToken:
if err = client.DeleteToken(ctx, rc.ref.Name); err != nil {
return trace.Wrap(err)
}
fmt.Printf("token %q has been deleted\n", rc.ref.Name)
case types.KindSAMLConnector:
if err = client.DeleteSAMLConnector(ctx, rc.ref.Name); err != nil {
return trace.Wrap(err)
Expand Down
2 changes: 1 addition & 1 deletion tool/tctl/common/token_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func (c *TokenCommand) Initialize(app *kingpin.Application, config *service.Conf

// tctl tokens add ..."
c.tokenAdd = tokens.Command("add", "Create a invitation token")
c.tokenAdd.Flag("type", "Type of token to add").Required().StringVar(&c.tokenType)
c.tokenAdd.Flag("type", "Type(s) of token to add, e.g. --type=node,app,db").Required().StringVar(&c.tokenType)
c.tokenAdd.Flag("value", "Value of token to add").StringVar(&c.value)
c.tokenAdd.Flag("labels", "Set token labels, e.g. env=prod,region=us-west").StringVar(&c.labels)
c.tokenAdd.Flag("ttl", fmt.Sprintf("Set expiration time for token, default is %v hour",
Expand Down

0 comments on commit 5dadc57

Please sign in to comment.