Skip to content

Commit 05c8c47

Browse files
dadlerjburmudar
authored andcommitted
Add tip to set env var after login (#1286)
1 parent e3e0140 commit 05c8c47

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

‎cmd/src/login.go‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,11 @@ func loginCmd(ctx context.Context, p loginParams) error {
106106
}
107107

108108
_, flow := selectLoginFlow(p)
109-
return flow(ctx, p)
109+
if err := flow(ctx, p); err != nil {
110+
return err
111+
}
112+
fmt.Fprintf(p.out, "\n💡 Tip: To use this endpoint in your shell, run:\n\n export SRC_ENDPOINT=%s\n\n", p.cfg.Endpoint)
113+
return nil
110114
}
111115

112116
// selectLoginFlow decides what login flow to run based on configured AuthMode.

‎cmd/src/login_test.go‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@ func TestLogin(t *testing.T) {
102102
if err != nil {
103103
t.Fatal(err)
104104
}
105-
wantOut := "✔︎ Authenticated as alice on $ENDPOINT"
106-
wantOut = strings.ReplaceAll(wantOut, "$ENDPOINT", endpoint)
105+
wantOut := "✔︎ Authenticated as alice on $ENDPOINT\n\n\n💡 Tip: To use this endpoint in your shell, run:\n\n export SRC_ENDPOINT=$ENDPOINT"
106+
wantOut = strings.ReplaceAll(wantOut, "$ENDPOINT", s.URL)
107107
if out != wantOut {
108108
t.Errorf("got output %q, want %q", out, wantOut)
109109
}
@@ -143,7 +143,7 @@ func TestLogin(t *testing.T) {
143143
t.Fatal("expected stored oauth token to avoid device flow")
144144
}
145145
gotOut := strings.TrimSpace(out.String())
146-
wantOut := "✔︎ Authenticated as alice on $ENDPOINT\n\n\n✔︎ Authenticated with OAuth credentials"
146+
wantOut := "✔︎ Authenticated as alice on $ENDPOINT\n\n\n✔︎ Authenticated with OAuth credentials\n\n💡 Tip: To use this endpoint in your shell, run:\n\n export SRC_ENDPOINT=$ENDPOINT"
147147
wantOut = strings.ReplaceAll(wantOut, "$ENDPOINT", s.URL)
148148
if gotOut != wantOut {
149149
t.Errorf("got output %q, want %q", gotOut, wantOut)

0 commit comments

Comments
 (0)