cli: show warning when creating token if policy doesn't exist (#16437)

This commit is contained in:
Farbod Ahmadian
2024-08-08 17:04:55 +02:00
committed by GitHub
parent 9543e740af
commit bb4c4fbd49
2 changed files with 11 additions and 0 deletions

3
.changelog/16437.txt Normal file
View File

@@ -0,0 +1,3 @@
```release-note:improvement
cli: `acl token create` will now emit a warning if the token has a policy that does not yet exist
```

View File

@@ -154,6 +154,14 @@ func (c *ACLTokenCreateCommand) Run(args []string) int {
return 1
}
// Show warning if policy doesn't exist
for _, policy := range tk.Policies {
_, _, err := client.ACLPolicies().Info(policy, nil)
if err != nil {
c.Ui.Warn(fmt.Sprintf("Error fetching info on %s policy: %s", policy, err))
}
}
// Create the bootstrap token
token, _, err := client.ACLTokens().Create(tk, nil)
if err != nil {