Skip to content

Commit b51932d

Browse files
matifaliciregoParkreiner
authored
feat(dotfiles): Add an optional coder_app to update dotfiles on-demand (coder#280)
Co-authored-by: Chris Golden <551285+cirego@users.noreply.github.com> Co-authored-by: Michael Smith <throwawayclover@gmail.com>
1 parent 834ffde commit b51932d

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

dotfiles/main.tf

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,14 @@ variable "coder_parameter_order" {
3939
default = null
4040
}
4141

42-
data "coder_parameter" "dotfiles_uri" {
43-
count = var.dotfiles_uri == null ? 1 : 0
42+
variable "manual_update" {
43+
type = bool
44+
description = "If true, this adds a button to workspace page to refresh dotfiles on demand."
45+
default = false
46+
}
4447

48+
data "coder_parameter" "dotfiles_uri" {
49+
count = var.dotfiles_uri == null ? 1 : 0
4550
type = "string"
4651
name = "dotfiles_uri"
4752
display_name = "Dotfiles URL"
@@ -68,6 +73,18 @@ resource "coder_script" "dotfiles" {
6873
run_on_start = true
6974
}
7075

76+
resource "coder_app" "dotfiles" {
77+
count = var.manual_update ? 1 : 0
78+
agent_id = var.agent_id
79+
display_name = "Refresh Dotfiles"
80+
slug = "dotfiles"
81+
icon = "/icon/dotfiles.svg"
82+
command = templatefile("${path.module}/run.sh", {
83+
DOTFILES_URI : local.dotfiles_uri,
84+
DOTFILES_USER : local.user
85+
})
86+
}
87+
7188
output "dotfiles_uri" {
7289
description = "Dotfiles URI"
7390
value = local.dotfiles_uri

0 commit comments

Comments
 (0)