add flags to control if developers can update

pull/47/head
Muhammad Atif Ali 2 years ago
parent 5e53845540
commit 96cec772c1
No known key found for this signature in database

@ -14,22 +14,36 @@ variable "agent_id" {
description = "The ID of a Coder agent." description = "The ID of a Coder agent."
} }
variable "allow_username_change" {
type = bool
description = "Allow developers to change their git username."
default = true
}
variable "allow_email_change" {
type = bool
description = "Allow developers to change their git email."
default = false
}
data "coder_parameter" "user_email" { data "coder_parameter" "user_email" {
count = var.allow_email_change ? 1 : 0
name = "user_email" name = "user_email"
type = "string" type = "string"
default = data.coder_workspace.me.owner_email default = data.coder_workspace.me.owner_email
description = "Git user.email to be used for commits" description = "Git user.email to be used for commits"
display_name = "Git config user.email" display_name = "Git config user.email"
mutable = false mutable = true
} }
data "coder_parameter" "username" { data "coder_parameter" "username" {
count = var.allow_username_change ? 1 : 0
name = "username" name = "username"
type = "string" type = "string"
default = data.coder_workspace.me.owner default = data.coder_workspace.me.owner
description = "Git user.name to be used for commits" description = "Git user.name to be used for commits"
display_name = "Git config user.name" display_name = "Git config user.name"
mutable = false mutable = true
} }
data "coder_workspace" "me" {} data "coder_workspace" "me" {}
@ -37,8 +51,8 @@ data "coder_workspace" "me" {}
resource "coder_script" "git_config" { resource "coder_script" "git_config" {
agent_id = var.agent_id agent_id = var.agent_id
script = templatefile("${path.module}/run.sh", { script = templatefile("${path.module}/run.sh", {
CODER_USERNAME = data.coder_parameter.username.value CODER_USERNAME = try(data.coder_parameter.username.value, data.coder_workspace.me.owner)
CODER_EMAIL = data.coder_parameter.user_email.value CODER_EMAIL = try(data.coder_parameter.user_email.value, data.coder_workspace.me.owner_email)
}) })
display_name = "Git Config" display_name = "Git Config"
icon = "/icon/git.svg" icon = "/icon/git.svg"

Loading…
Cancel
Save