From 3f8f6181e0a67115145cfd8cf00c8bc58f291600 Mon Sep 17 00:00:00 2001 From: Parkreiner Date: Mon, 1 Jul 2024 20:31:43 +0000 Subject: [PATCH] refactor: clean up final code --- windows-rdp/devolutions-patch.js | 9 ++++----- windows-rdp/main.tf | 6 +++++- ...lation.tftpl => powershell-installation-script.tftpl} | 0 3 files changed, 9 insertions(+), 6 deletions(-) rename windows-rdp/{windows-installation.tftpl => powershell-installation-script.tftpl} (100%) diff --git a/windows-rdp/devolutions-patch.js b/windows-rdp/devolutions-patch.js index a1e9da4..020a40f 100644 --- a/windows-rdp/devolutions-patch.js +++ b/windows-rdp/devolutions-patch.js @@ -12,11 +12,10 @@ * - A lot of the HTML selectors in this file will look nonstandard. This is * because they are actually custom Angular components. * - It is strongly advised that you avoid template literals that use the - * placeholder syntax via the dollar sign. The Terraform script looks for - * these characters so that it can inject Coder-specific values, so any - * template literal that uses the character actually needs to double up each - * of them. There are already a few places in this file where it couldn't be - * avoided, but avoiding this as much as possible will save you some headache. + * placeholder syntax via the dollar sign. The Terraform file is treating this + * as a template file, and because it also uses a similar syntax, there's a + * risk that some values will trigger false positives. If a template literal + * must be used, be sure to use a double dollar sign to escape things. * - All the CSS should be written via custom style tags and the !important * directive (as much as that is a bad idea most of the time). We do not * control the Angular app, so we have to modify things from afar to ensure diff --git a/windows-rdp/main.tf b/windows-rdp/main.tf index f47e94e..563e10f 100644 --- a/windows-rdp/main.tf +++ b/windows-rdp/main.tf @@ -35,9 +35,13 @@ resource "coder_script" "windows-rdp" { display_name = "windows-rdp" icon = "https://svgur.com/i/158F.svg" # TODO: add to Coder icons - script = templatefile("${path.module}/windows-installation.tftpl", { + script = templatefile("${path.module}/powershell-installation-script.tftpl", { admin_username = var.admin_username admin_password = var.admin_password + + # Wanted to have this be in the powershell template file, but Terraform + # doesn't allow recursive calls to the templatefile function. Have to feed + # results of the JS template replace into the powershell template patch_file_contents = templatefile("${path.module}/devolutions-patch.js", { CODER_USERNAME = var.admin_username CODER_PASSWORD = var.admin_password diff --git a/windows-rdp/windows-installation.tftpl b/windows-rdp/powershell-installation-script.tftpl similarity index 100% rename from windows-rdp/windows-installation.tftpl rename to windows-rdp/powershell-installation-script.tftpl