-
Notifications
You must be signed in to change notification settings - Fork 891
Pass git configuration variables via terraform #3034
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Updated to no longer pass an |
examples/templates/do-linux/main.tf
Outdated
env = { | ||
GIT_AUTHOR_NAME = "${data.coder_workspace.me.owner}" | ||
GIT_COMMITTER_NAME = "${data.coder_workspace.me.owner}" | ||
GIT_AUTHOR_EMAIL = "${data.coder_workspace.me.owner_email}" | ||
GIT_COMMITTER_EMAIL = "${data.coder_workspace.me.owner_email}" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should add this to our docs (which you can do in this PR too), but we shouldn't do it in all templates. I think it could give the perception that this is mandatory when it certainly isn't.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense. In that case I'd lean towards including it in the docker
and docker-code-server
templates, since those are the ones that are most likely to be used for a "quickstart", and removing it from the others. I'll add documentation as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with that. Makes sense to me!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like a really nice UX improvement - thanks for adding to the docker-code-server
template too! 🎉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ammario is going to review the docs (he's been doing a buncha that), but the code looks great to me!
Awesome change, and good investigation 🕵️🥳
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This turned out really nice!
docs/templates.md
Outdated
for more information. | ||
|
||
For example, the [Docker quick-start template](https://github.com/coder/coder/tree/main/examples/templates/docker) | ||
sets a few environment variables based on the username and email address of the user's owner, so |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sets a few environment variables based on the username and email address of the user's owner, so | |
sets a few environment variables based on the username and email address of the workspace's owner, so |
docs/templates.md
Outdated
} | ||
``` | ||
|
||
You can add these variable definitions to your own templates, or customize them however you like. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can add these variable definitions to your own templates, or customize them however you like. | |
You can add these environment variable definitions to your own templates, or customize them however you like. |
@@ -39,6 +39,17 @@ resource "coder_agent" "dev" { | |||
arch = var.docker_arch | |||
os = "linux" | |||
startup_script = "code-server --auth none" | |||
|
|||
# These environment variables allow you to make Git commits right away after creating a | |||
# workspace. Note that they take precedence over configuration defined in ~/.gitconfig! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❤️ For calling out this behavior!
This PR removes the hard-coded agent functionality that sets
GIT_*
environment variables automatically. Instead, we pass the username and email address of the workspace owner to the Terraform provisioner, so that users can explicitly configure this behavior with theenv
block of thecoder_agent
resource:I've also added this configuration to the
docker
anddocker-code-server
example templates.Depends on the corresponding provider change in coder/terraform-provider-coder#31 to add the new
owner_email
data source attribute.Fixes #2665, obsoletes #2980, obsoletes #2981