This repository was archived by the owner on May 15, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 6 files changed +87
-0
lines changed Expand file tree Collapse file tree 6 files changed +87
-0
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ display_name : Coder Login
3
+ description : Automatically logs the user into Coder on their workspace
4
+ icon : ../.icons/coder-white.svg
5
+ maintainer_github : coder
6
+ verified : true
7
+ tags : [helper]
8
+ ---
9
+
10
+ # Coder Login
11
+
12
+ Automatically logs the user into Coder when creating their workspace.
13
+
14
+ ``` hcl
15
+ module "coder-login" {
16
+ agent_id = coder_agent.example.id
17
+ }
18
+ ```
19
+
20
+ ![ Coder Login Logs] ( ../.images/coder-login.png )
Original file line number Diff line number Diff line change
1
+ import { describe , expect , it } from "bun:test" ;
2
+ import {
3
+ executeScriptInContainer ,
4
+ runTerraformApply ,
5
+ runTerraformInit ,
6
+ testRequiredVariables ,
7
+ } from "../test" ;
8
+
9
+ describe ( "coder-login" , async ( ) => {
10
+ await runTerraformInit ( import . meta. dir ) ;
11
+
12
+ testRequiredVariables ( import . meta. dir , {
13
+ agent_id : "foo" ,
14
+ } ) ;
15
+ } ) ;
Original file line number Diff line number Diff line change
1
+ terraform {
2
+ required_version = " >= 1.0"
3
+
4
+ required_providers {
5
+ coder = {
6
+ source = " coder/coder"
7
+ version = " >= 0.12"
8
+ }
9
+ }
10
+ }
11
+
12
+ variable "agent_id" {
13
+ type = string
14
+ description = " The ID of a Coder agent."
15
+ }
16
+
17
+ data "coder_workspace" "me" {}
18
+
19
+ resource "coder_script" "coder-login" {
20
+ agent_id = var. agent_id
21
+ script = templatefile (" ${ path . module } /run.sh" , {
22
+ CODER_USER_TOKEN : data.coder_workspace.me.owner_session_token,
23
+ CODER_DEPLOYMENT_URL : data.coder_workspace.me.access_url
24
+ })
25
+ display_name = " Coder Login"
26
+ icon = " http://svgur.com/i/y5G.svg"
27
+ run_on_start = true
28
+ start_blocks_login = true
29
+ }
30
+
Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env sh
2
+
3
+ # Automatically authenticate the user if they are not
4
+ # logged in to another deployment
5
+
6
+ BOLD=' \033[0;1m'
7
+
8
+ printf " $$ {BOLD}Logging into Coder...\n\n$$ {RESET}"
9
+
10
+ if ! coder list > /dev/null 2>&1 ; then
11
+ set +x; coder login --token=" ${CODER_USER_TOKEN} " --url=" ${CODER_DEPLOYMENT_URL} "
12
+ else
13
+ echo " You are already authenticated with coder."
14
+ fi
You can’t perform that action at this time.
0 commit comments