From 500888714428f1b436cc9946e24cb75f0e8c814b Mon Sep 17 00:00:00 2001 From: Muhammad Atif Ali Date: Wed, 27 Sep 2023 12:28:10 +0300 Subject: [PATCH] refactor --- git-config/main.tf | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/git-config/main.tf b/git-config/main.tf index a6a4c28..8f0d997 100644 --- a/git-config/main.tf +++ b/git-config/main.tf @@ -14,23 +14,11 @@ variable "agent_id" { description = "The ID of a Coder agent." } -# TODO: Test if the workspace owner name and email can be pulled from the module -variable "default_username" { - type = string - description = "The username of the Coder workspace owner." -} - -variable "default_user_email" { - type = string - description = "The email of the Coder workspace owner." -} - - data "coder_parameter" "user_email" { name = "user_email" type = "string" - default = "default" - description = "Email to store in git-config for this workspace. Leave as \"default\" to populate with workspace owner email or admin preset." + default = data.coder_workspace.me.owner_email + description = "Git user.email to be used for commits" display_name = "Git config user.email" mutable = false } @@ -38,17 +26,19 @@ data "coder_parameter" "user_email" { data "coder_parameter" "username" { name = "username" type = "string" - default = "default" - description = "Username to store in git-config for this workspace. Leave as \"default\" to populate with workspace owner name or admin preset." + default = data.coder_workspace.me.owner + description = "Git user.name to be used for commits" display_name = "Git config user.name" mutable = false } +data "coder_workspace" "me" {} + resource "coder_script" "git_config" { agent_id = var.agent_id script = templatefile("${path.module}/run.sh", { - CODER_USERNAME = data.coder_parameter.username.value != "default" ? data.coder_parameter.username.value : var.default_username, - CODER_EMAIL = data.coder_parameter.user_email.value != "default" ? data.coder_parameter.user_email.value : var.default_user_email + CODER_USERNAME = data.coder_parameter.username.value + CODER_EMAIL = data.coder_parameter.user_email.value }) display_name = "Git Config" icon = "/icon/git.svg"