File tree Expand file tree Collapse file tree 3 files changed +33
-5
lines changed
registry/coder/modules/zed Expand file tree Collapse file tree 3 files changed +33
-5
lines changed Original file line number Diff line number Diff line change @@ -48,3 +48,15 @@ module "zed" {
4848 order = 1
4949}
5050```
51+
52+ ### With custom agent name
53+
54+ ``` tf
55+ module "zed" {
56+ count = data.coder_workspace.me.start_count
57+ source = "registry.coder.com/coder/zed/coder"
58+ version = "1.0.0"
59+ agent_id = coder_agent.example.id
60+ agent_name = coder_agent.example.name
61+ }
62+ ```
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ describe("zed", async () => {
1717 agent_id : "foo" ,
1818 } ) ;
1919 expect ( state . outputs . zed_url . value ) . toBe (
20- "zed://ssh/default.default. coder/ " ,
20+ "zed://ssh/default.coder" ,
2121 ) ;
2222
2323 const coder_app = state . resources . find (
@@ -35,7 +35,7 @@ describe("zed", async () => {
3535 folder : "/foo/bar" ,
3636 } ) ;
3737 expect ( state . outputs . zed_url . value ) . toBe (
38- "zed://ssh/default.default. coder/foo/bar" ,
38+ "zed://ssh/default.coder/foo/bar" ,
3939 ) ;
4040 } ) ;
4141
@@ -68,4 +68,14 @@ describe("zed", async () => {
6868 expect ( coder_app ?. instances . length ) . toBe ( 1 ) ;
6969 expect ( coder_app ?. instances [ 0 ] . attributes . display_name ) . toBe ( "Custom Zed" ) ;
7070 } ) ;
71+
72+ it ( "adds agent_name to hostname" , async ( ) => {
73+ const state = await runTerraformApply ( import . meta. dir , {
74+ agent_id : "foo" ,
75+ agent_name : "myagent" ,
76+ } ) ;
77+ expect ( state . outputs . zed_url . value ) . toBe (
78+ "zed://ssh/myagent.default.me.coder" ,
79+ ) ;
80+ } ) ;
7181} ) ;
Original file line number Diff line number Diff line change @@ -14,6 +14,12 @@ variable "agent_id" {
1414 description = " The ID of a Coder agent."
1515}
1616
17+ variable "agent_name" {
18+ type = string
19+ description = " The name of the agent."
20+ default = " "
21+ }
22+
1723variable "folder" {
1824 type = string
1925 description = " The folder to open in Zed IDE."
@@ -49,8 +55,8 @@ data "coder_workspace_owner" "me" {}
4955
5056locals {
5157 workspace_name = lower (data. coder_workspace . me . name )
52- owner_name = lower (data . coder_workspace_owner . me . name )
53- hostname = " ${ local . workspace_name } .${ local . owner_name } .coder"
58+ agent_name = lower (var . agent_name )
59+ hostname = var . agent_name != " " ? " ${ local . agent_name } . ${ local . workspace_name } .me.coder " : " ${ local . workspace_name } .coder"
5460}
5561
5662resource "coder_app" "zed" {
@@ -61,7 +67,7 @@ resource "coder_app" "zed" {
6167 external = true
6268 order = var. order
6369 group = var. group
64- url = " zed://ssh/${ local . hostname } /${ var . folder } "
70+ url = " zed://ssh/${ local . hostname } ${ var . folder != " " ? " /${ var . folder } " : " " } "
6571}
6672
6773output "zed_url" {
You can’t perform that action at this time.
0 commit comments