@@ -20,13 +20,8 @@ data "coder_workspace_owner" "me" {}
20
20
21
21
variable "agent_name" {
22
22
type = string
23
- description = " The name of the main deployment. (Used to build the subpath for coder_app.)"
24
- default = " "
25
- validation {
26
- # If subdomain is false, then agent_name must be set.
27
- condition = var. subdomain || var. agent_name != " "
28
- error_message = " The agent_name must be set."
29
- }
23
+ description = " The name of the coder_agent resource. (Only required if subdomain is false and the template uses multiple agents.)"
24
+ default = null
30
25
}
31
26
32
27
variable "database_path" {
@@ -73,6 +68,12 @@ variable "order" {
73
68
default = null
74
69
}
75
70
71
+ variable "slug" {
72
+ type = string
73
+ description = " The slug of the coder_app resource."
74
+ default = " filebrowser"
75
+ }
76
+
76
77
variable "subdomain" {
77
78
type = bool
78
79
description = <<- EOT
@@ -85,26 +86,38 @@ variable "subdomain" {
85
86
resource "coder_script" "filebrowser" {
86
87
agent_id = var. agent_id
87
88
display_name = " File Browser"
88
- icon = " https://raw.githubusercontent.com/ filebrowser/logo/master/icon_raw .svg"
89
+ icon = " /icon/ filebrowser.svg"
89
90
script = templatefile (" ${ path . module } /run.sh" , {
90
91
LOG_PATH : var.log_path,
91
92
PORT : var.port,
92
93
FOLDER : var.folder,
93
94
LOG_PATH : var.log_path,
94
95
DB_PATH : var.database_path,
95
96
SUBDOMAIN : var.subdomain,
96
- SERVER_BASE_PATH : var.subdomain ? " " : format ( " /@%s/%s.%s/apps/filebrowser " , data . coder_workspace_owner . me . name , data . coder_workspace . me . name , var . agent_name ),
97
+ SERVER_BASE_PATH : local.server_base_path
97
98
})
98
99
run_on_start = true
99
100
}
100
101
101
102
resource "coder_app" "filebrowser" {
102
103
agent_id = var. agent_id
103
- slug = " filebrowser "
104
+ slug = var . slug
104
105
display_name = " File Browser"
105
- url = " http://localhost: ${ var . port } "
106
- icon = " https://raw.githubusercontent.com/ filebrowser/logo/master/icon_raw .svg"
106
+ url = local . url
107
+ icon = " /icon/ filebrowser.svg"
107
108
subdomain = var. subdomain
108
109
share = var. share
109
110
order = var. order
111
+
112
+ healthcheck {
113
+ url = local. healthcheck_url
114
+ interval = 5
115
+ threshold = 6
116
+ }
110
117
}
118
+
119
+ locals {
120
+ server_base_path = var. subdomain ? " " : format (" /@%s/%s%s/apps/%s" , data. coder_workspace_owner . me . name , data. coder_workspace . me . name , var. agent_name != null ? " .${ var . agent_name } " : " " , var. slug )
121
+ url = " http://localhost:${ var . port } ${ local . server_base_path } "
122
+ healthcheck_url = " http://localhost:${ var . port } ${ local . server_base_path } /health"
123
+ }
0 commit comments