Skip to content

Commit f5829d2

Browse files
authored
chore(dogfood): authenticate to coder CLI if unauthenticated (#9487)
1 parent 05439d2 commit f5829d2

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

dogfood/main.tf

+11
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ resource "coder_agent" "dev" {
9090
env = {
9191
GITHUB_TOKEN : data.coder_git_auth.github.access_token,
9292
OIDC_TOKEN : data.coder_workspace.me.owner_oidc_access_token,
93+
CODER_USER_TOKEN : data.coder_workspace.me.owner_session_token,
94+
CODER_DEPLOYMENT_URL : data.coder_workspace.me.access_url
9395
}
9496
startup_script_behavior = "blocking"
9597

@@ -202,6 +204,15 @@ resource "coder_agent" "dev" {
202204
elif [ -f ~/personalize ]; then
203205
echo "~/personalize is not executable, skipping..." | tee -a ~/.personalize.log
204206
fi
207+
208+
# Automatically authenticate the user if they are not
209+
# logged in to another deployment
210+
if ! coder list >/dev/null 2>&1; then
211+
set +x; coder login --token=$CODER_USER_TOKEN --url=$CODER_DEPLOYMENT_URL
212+
else
213+
echo "You are already authenticated with coder"
214+
fi
215+
205216
EOT
206217
}
207218

0 commit comments

Comments
 (0)