fix: remove irrelevant help info from `coder tokens create` (#7135)

The additional text didn't help much, and made it much harder to script around.
This commit is contained in:
Kyle Carberry 2023-04-14 12:18:01 -05:00 committed by GitHub
parent f36a4a0b07
commit 7f12020229
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 15 deletions

View File

@ -3,7 +3,6 @@ package cli
import (
"fmt"
"os"
"strings"
"time"
"golang.org/x/exp/slices"
@ -67,14 +66,7 @@ func (r *RootCmd) createToken() *clibase.Cmd {
return xerrors.Errorf("create tokens: %w", err)
}
cliui.Infof(
inv.Stdout,
"Here is your token. 🪄\n\n",
)
cliui.Infof(inv.Stdout, cliui.Styles.Code.Render(strings.TrimSpace(res.Key))+"\n\n")
cliui.Infof(inv.Stdout,
"You can use this token by setting the --%s CLI flag, the %s environment variable, or the %q HTTP header.", varToken, envSessionToken, codersdk.SessionTokenHeader,
)
_, _ = fmt.Fprintln(inv.Stdout, res.Key)
return nil
},

View File

@ -4,7 +4,6 @@ import (
"bytes"
"context"
"encoding/json"
"regexp"
"testing"
"github.com/stretchr/testify/require"
@ -41,11 +40,7 @@ func TestTokens(t *testing.T) {
require.NoError(t, err)
res = buf.String()
require.NotEmpty(t, res)
// find API key in format "XXXXXXXXXX-XXXXXXXXXXXXXXXXXXXXXX"
r := regexp.MustCompile("[a-zA-Z0-9]{10}-[a-zA-Z0-9]{22}")
require.Regexp(t, r, res)
key := r.FindString(res)
id := key[:10]
id := res[:10]
inv, root = clitest.New(t, "tokens", "ls")
clitest.SetupConfig(t, client, root)