From 20bc42715258c5d29a4dd948b6e334dd59aa0cec Mon Sep 17 00:00:00 2001 From: Stephen Kirby Date: Wed, 27 Sep 2023 21:04:47 +0000 Subject: [PATCH] reverted to passing in email/username source --- git-config/main.tf | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/git-config/main.tf b/git-config/main.tf index e5066b5..f4d8fc2 100644 --- a/git-config/main.tf +++ b/git-config/main.tf @@ -26,13 +26,23 @@ variable "allow_email_change" { default = false } -data "coder_workspace" "git_config" {} +variable "default_username_source" { + string = string + description = "Default source to use for git-config user.name." +} + +variable "default_email_source" { + string = string + description = "Default source to use for git-config user.email." +} + +# data "coder_workspace" "me" {} data "coder_parameter" "user_email" { count = var.allow_email_change ? 1 : 0 name = "user_email" type = "string" - default = data.coder_workspace.git_config.owner_email + default = var.default_email_source description = "Git user.email to be used for commits" display_name = "Git config user.email" mutable = true @@ -42,7 +52,7 @@ data "coder_parameter" "username" { count = var.allow_username_change ? 1 : 0 name = "username" type = "string" - default = data.coder_workspace.git_config.owner + default = var.default_email_source description = "Git user.name to be used for commits" display_name = "Git config user.name" mutable = true @@ -51,10 +61,15 @@ data "coder_parameter" "username" { resource "coder_script" "git_config" { agent_id = var.agent_id script = templatefile("${path.module}/run.sh", { - GIT_USERNAME = try(data.coder_parameter.username[0].value, data.coder_workspace.git_config.owner) - GIT_EMAIL = try(data.coder_parameter.user_email[0].value, data.coder_workspace.git_config.owner_email) + GIT_USERNAME = try(data.coder_parameter.username[0].value, var.default_username_source) + GIT_EMAIL = try(data.coder_parameter.user_email[0].value, var.default_email_source) }) display_name = "Git Config" icon = "/icon/git.svg" run_on_start = true } + + +# Old implementation, saving for testing + # GIT_USERNAME = try(data.coder_parameter.username[0].value, data.coder_workspace.git_config.owner) + # GIT_EMAIL = try(data.coder_parameter.user_email[0].value, data.coder_workspace.git_config.owner_email) \ No newline at end of file