Skip to content

chore(dogfood): authenticate to coder CLI if unauthenticated #9487

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 3, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
chore(dogfood): auth to coder CLI if unauthenticated
  • Loading branch information
bpmct committed Sep 1, 2023
commit cfa40e079944ca452b746d67a07928dd373842ba
11 changes: 11 additions & 0 deletions dogfood/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ resource "coder_agent" "dev" {
env = {
GITHUB_TOKEN : data.coder_git_auth.github.access_token,
OIDC_TOKEN : data.coder_workspace.me.owner_oidc_access_token,
CODER_USER_TOKEN : data.coder_workspace.me.owner_session_token,
CODER_DEPLOYMENT_URL : data.coder_workspace.me.access_url
}
startup_script_behavior = "blocking"

Expand Down Expand Up @@ -202,6 +204,15 @@ resource "coder_agent" "dev" {
elif [ -f ~/personalize ]; then
echo "~/personalize is not executable, skipping..." | tee -a ~/.personalize.log
fi

# Automatically authenticate the user if they are not
# logged in to another deployment
if ! coder list >/dev/null 2>&1; then
set +x; coder login --token=$CODER_USER_TOKEN --url=$CODER_DEPLOYMENT_URL
else
echo "You are already authenticated with coder"
fi

EOT
}

Expand Down