From 89e0766f9ee809ff3369e82ed13f4026e70ebf98 Mon Sep 17 00:00:00 2001 From: Stephen Kirby Date: Wed, 27 Sep 2023 22:17:58 +0000 Subject: [PATCH] finalized functionality of git-config, needs tests --- git-config/main.test.ts | 8 ++++++-- git-config/main.tf | 8 ++++---- git-config/run.sh | 4 ++-- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/git-config/main.test.ts b/git-config/main.test.ts index 4c0d309..4d71cfe 100644 --- a/git-config/main.test.ts +++ b/git-config/main.test.ts @@ -11,13 +11,15 @@ describe("git-config", async () => { testRequiredVariables(import.meta.dir, { agent_id: "foo", + allow_username_change: true, + allow_email_change: true, }); it("fails without git", async () => { const state = await runTerraformApply(import.meta.dir, { agent_id: "foo", - allow_username_change: false, - allow_email_change: false, + allow_username_change: true, + allow_email_change: true, }); const output = await executeScriptInContainer(state, "alpine"); expect(output.exitCode).toBe(1); @@ -30,6 +32,8 @@ describe("git-config", async () => { it("runs with git", async () => { const state = await runTerraformApply(import.meta.dir, { agent_id: "foo", + allow_username_change: true, + allow_email_change: true, }); const output = await executeScriptInContainer(state, "alpine/git"); expect(output.exitCode).toBe(0); diff --git a/git-config/main.tf b/git-config/main.tf index 658919b..7f56198 100644 --- a/git-config/main.tf +++ b/git-config/main.tf @@ -17,7 +17,7 @@ variable "agent_id" { variable "allow_username_change" { type = bool description = "Allow developers to change their git username." - default = false + default = true } variable "allow_email_change" { @@ -33,8 +33,8 @@ data "coder_parameter" "user_email" { count = var.allow_email_change ? 1 : 0 name = "user_email" type = "string" - default = "" #var.default_email_source - description = "Git user.email to be used for commits" + default = "" + description = "Git user.email to be used for commits. Leave empty to default to Coder username." display_name = "Git config user.email" mutable = true } @@ -44,7 +44,7 @@ data "coder_parameter" "username" { name = "username" type = "string" default = "" - description = "Git user.name to be used for commits" + description = "Git user.name to be used for commits. Leave empty to default to Coder username." display_name = "Git config user.name" mutable = true } diff --git a/git-config/run.sh b/git-config/run.sh index a517284..586be4d 100644 --- a/git-config/run.sh +++ b/git-config/run.sh @@ -20,5 +20,5 @@ if [ -z $(git config --get user.name) ]; then git config --global user.name "${GIT_USERNAME}" fi -printf "$${BOLD}git-config: using email: $(git config --get user.email)\n" -printf "\n$${BOLD}git-config: using username: $(git config --get user.name)\n\n" +printf "\n$${BOLD}git-config: using email: $(git config --get user.email)\n" +printf "$${BOLD}git-config: using username: $(git config --get user.name)\n\n"