From 5a568d8a9b1ae45c72ae01076d1a37067ef9a659 Mon Sep 17 00:00:00 2001 From: Joe Previte Date: Tue, 13 Dec 2022 14:15:25 -0700 Subject: [PATCH] refactor: conditionally use dotfiles in dogfood template (#5332) * feat: add dotfiles_uri var to dogfood template * refactor: use dotfiles if dotfiles var exists This ensures the `coder dotfiles` command only runs if the dotfiles var in the template is not empty. * Update dogfood/main.tf * refactor: assign variable to shell variable * Update dogfood/main.tf * fixup!: add default value --- dogfood/main.tf | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/dogfood/main.tf b/dogfood/main.tf index 5032ffb66f..0727a8cb1f 100644 --- a/dogfood/main.tf +++ b/dogfood/main.tf @@ -11,6 +11,19 @@ terraform { } } +# User parameters + +variable "dotfiles_uri" { + type = string + description = <<-EOF + default = "" + Dotfiles repo URI (optional) + + see https://dotfiles.github.io + EOF + default = "" +} + variable "datocms_api_token" { type = string description = "An API token from DATOCMS for usage with building our website." @@ -39,7 +52,10 @@ resource "coder_agent" "dev" { curl -fsSL https://code-server.dev/install.sh | sh -s -- --version 4.8.3 code-server --auth none --port 13337 & sudo service docker start - coder dotfiles -y 2>&1 | tee ~/.personalize.log + DOTFILES_URI=${var.dotfiles_uri} + if [ -n "$DOTFILES_URI" ]; then + coder dotfiles var.dotfiles_uri -y 2>&1 | tee ~/.personalize.log + fi EOF }