Skip to content

Commit d1c6986

Browse files
authored
fix: provide environment variable for CLI session token (#2648)
1 parent 6aed58f commit d1c6986

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

cli/root.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ const (
3939
varNoOpen = "no-open"
4040
varForceTty = "force-tty"
4141
notLoggedInMessage = "You are not logged in. Try logging in using 'coder login <url>'."
42+
43+
envSessionToken = "CODER_SESSION_TOKEN"
4244
)
4345

4446
func init() {
@@ -95,7 +97,7 @@ func Root() *cobra.Command {
9597
cmd.SetUsageTemplate(usageTemplate())
9698

9799
cmd.PersistentFlags().String(varURL, "", "Specify the URL to your deployment.")
98-
cmd.PersistentFlags().String(varToken, "", "Specify an authentication token.")
100+
cliflag.String(cmd.PersistentFlags(), varToken, "", envSessionToken, "", fmt.Sprintf("Specify an authentication token. For security reasons setting %s is preferred.", envSessionToken))
99101
cliflag.String(cmd.PersistentFlags(), varAgentToken, "", "CODER_AGENT_TOKEN", "", "Specify an agent authentication token.")
100102
_ = cmd.PersistentFlags().MarkHidden(varAgentToken)
101103
cliflag.String(cmd.PersistentFlags(), varAgentURL, "", "CODER_AGENT_URL", "", "Specify the URL for an agent to access your deployment.")

0 commit comments

Comments
 (0)