-
Notifications
You must be signed in to change notification settings - Fork 936
feat: Read params from file for template/workspace creation #1541
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
@@ -18,6 +20,7 @@ func create() *cobra.Command { | |||
var ( | |||
workspaceName string | |||
templateName string | |||
parameterFile string |
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.
tfvars is the standard way to handle this with Terraform.
I'd prefer to not have our own solution, because that'd remove the ability for users to do terraform apply
.
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.
@kylecarbs that assumes we use terraform, but our cli should be terraform agnostic right?
Also tfvars
is just HCL or yaml. So we could just support multiple file types
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.
Developers also won't have the tf
file when running coder workspace create
, only the person who made the template will have the tf
file.
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.
We can be Terraform agnostic while still consuming tfvars
. Latching onto the existing Terraform ecosystem is a much better user experience than forking it with our own parameter format.
I don't believe it's necessary to have a tfvars
equivalent when creating a workspace. Or at least, we haven't seen it as a problem yet.
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.
Issue #1377 mentions creating workspaces using parameter files, which is why I went with a non-tfvars approach. However, #1426 does talk about doing this for templates. Would you recommend solving both problems using different approaches or only work on #1426 (template creation via file) via tfvars
? Let me quickly check how feasible using tfvars
for template creation is.
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.
Is there a documented flow of how the customers would use terraform apply
when setting up templates? I tried using the tfvars
file as follows:
$ terraform init
$ terraform apply -var-file="<path_to_tfvars>"
...
Apply complete! Resources: 3 added, 0 changed, 0 destroyed.
It did not create a template and calling coder templates create
after this still asked me for input, so I am not sure what the actual flow should be.
c7bb16f
to
dc80543
Compare
Interestingly, the error I am encountering in the Windows tests is a known Go issue: golang/go#52986. Trying a workaround. |
The fix does not help. What is the precedent in these cases? Revert the |
86b1028
to
1491620
Compare
* Read params from file for template/workspace creation * Use os.ReadFile * Refactor reading params into a separate module * Add comments and unit tests * Rename variable * Uncomment and fix unit test * Fix comment * Refactor tests * Fix unit tests for windows * Fix unit tests for Windows * Add comments for the hotfix
This allows users to use parameter files for variable input during template and workspace creation.
Subtasks
Fixes #1377