Doc and whitespace fixes for translate-rules command (#4877)

This commit is contained in:
Paul Banks 2018-10-31 17:28:04 +00:00 committed by GitHub
parent 70a051363f
commit d24a65eb8c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 2 deletions

View File

@ -4,6 +4,7 @@ import (
"flag"
"fmt"
"io"
"strings"
"github.com/hashicorp/consul/acl"
aclhelpers "github.com/hashicorp/consul/command/acl"
@ -34,7 +35,7 @@ type cmd struct {
func (c *cmd) init() {
c.flags = flag.NewFlagSet("", flag.ContinueOnError)
c.flags.BoolVar(&c.tokenAccessor, "token-accessor", false, "Specifies that "+
"the TRANSLATE argument refers to a ACL token SecretID. "+
"the TRANSLATE argument refers to a ACL token AccessorID. "+
"The rules to translate will then be read from the retrieved token")
c.flags.BoolVar(&c.tokenSecret, "token-secret", false,
@ -65,6 +66,9 @@ func (c *cmd) Run(args []string) int {
return 1
}
// Trim whitespace and newlines (e.g. from echo without -n)
data = strings.TrimSpace(data)
if rules, err := aclhelpers.GetRulesFromLegacyToken(client, data, c.tokenSecret); err != nil {
c.UI.Error(err.Error())
return 1
@ -127,7 +131,7 @@ Usage: consul acl translate-rules [options] TRANSLATE
Translate rules for a legacy ACL token using its SecretID passed from stdin:
$ consul acl translate-rules --token-secret -
$ consul acl translate-rules -token-secret -
Translate rules for a legacy ACL token using its AccessorID: