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."
}
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" {
count = var.allow_email_change ? 1 : 0
name = "user_email"
type = "string"
default = data.coder_workspace.me.owner_email
description = "Git user.email to be used for commits"
display_name = "Git config user.email"
mutable = false
mutable = true
}
data "coder_parameter" "username" {
count = var.allow_username_change ? 1 : 0
name = "username"
type = "string"
default = data.coder_workspace.me.owner
description = "Git user.name to be used for commits"
display_name = "Git config user.name"
mutable = false
mutable = true
}
data "coder_workspace" "me" {}
@ -37,8 +51,8 @@ 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
CODER_EMAIL = data.coder_parameter.user_email.value
CODER_USERNAME = try(data.coder_parameter.username.value, data.coder_workspace.me.owner)
CODER_EMAIL = try(data.coder_parameter.user_email.value, data.coder_workspace.me.owner_email)
})
display_name = "Git Config"
icon = "/icon/git.svg"

Loading…
Cancel
Save