Skip to content

feat: Allow partially filled out parameter files #5390

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

Closed
RickyGrassmuck opened this issue Dec 12, 2022 · 5 comments · Fixed by #5392
Closed

feat: Allow partially filled out parameter files #5390

RickyGrassmuck opened this issue Dec 12, 2022 · 5 comments · Fixed by #5392
Labels
cli Area: CLI

Comments

@RickyGrassmuck
Copy link
Contributor

RickyGrassmuck commented Dec 12, 2022

Summary

If using the --parameter-file option from the CLI, it requires that all of the templates defined variables be set otherwise it will fail with an error message stating a parameter is missing (Parameter value absent in parameter file for "<some-param>"!). If the CLI were capable of consuming partial parameter files and then interactively prompting for the missing parameters, it would make providing parameters that are used by many/all of a users workspaces simpler thus making for a smoother UX.

Example of the Current behavior

Command

coder create --template="openstack-server" --parameter-file="./test-params.yaml" test

Variables defined in the template

application_credential_id
application_credential_secret
openstack_ssh_key_name
image_name
vm_flavor

Parameter File Contents

application_credential_id: "<client-id>"
application_credential_secret: "<super-secret>"
openstack_ssh_key_name: "<my-keypair-name>"

Results

> coder create --template="openstack-server" --parameter-file="./test-params.yaml" test
                                                            
  Attempting to read the variables from the parameter file. 

                                                            
  This template has customizable parameters. Values can be  
  changed after create, but may have unintended side effects
  (like data loss).                                         

Parameter value absent in parameter file for "image_name"!
Run 'coder create --help' for usage.    

Feature Request

For many of the resources that we will be provisioning, there will be a common set of parameters being passed to coder by the user for provisioning resources1 with the remainder of parameters being used to customize the deployment (Things like image name, vm sizes etc).

If the CLI were able to load a partially filled out parameters file and then prompt the user for anything that it finds missing from that file, it would facilitate users being able to maintain parameter files with their common configuration choices to pass to the coder CLI and only require them to interactively provide the options for customizing that workspace resource.

Example mock up of what the same interaction would look like with the proposed feature

> coder create --template="openstack-server" --parameter-file="./personal-project-params.yaml" test
                                                            
  This template has customizable parameters. Values can be  
  changed after create, but may have unintended side effects
  (like data loss).                                         

  Parameters loaded from parameter-file:
    var.application_credential_id
    var.application_credential_secret
    var.openstack_ssh_key_name
  
  Obtaining remaining parameters interactively...

var.image_name
  Which Openstack image would you like to use for your workspace?

> Enter a value (default: "ubuntu-22.04"): <my-image-name>

var.vm_flavor
 What flavor name should be used for this Openstack instance?

> Enter a value (default: "c2.d20.r2048"): <my-flavor-name>

Planning workspace...
✔ Queued [513ms]
✔ Setting up [515ms]
✔ Detecting persistent resources [1618ms]
✔ Cleaning Up [127ms]
....

Footnotes

  1. We heavily provision on OpenStack and use individual OpenStack Projects for resource segregation. This results in requiring our users provide the necessary application credentials for the project they are deploying to so that coder can provision the resources.

@coadler coadler added the cli Area: CLI label Dec 12, 2022
@coadler
Copy link
Contributor

coadler commented Dec 12, 2022

I think this would be a great addition. I believe terraform has the same behavior, which I've found helpful in the past.

@RickyGrassmuck
Copy link
Contributor Author

Well, turns out its a dead simple code change to implement!

> coder create --template="openstack-server" --parameter-file="./testparams.yaml" test-2
                                                            
  Attempting to read the variables from the parameter file. 

                                                            
  This template has customizable parameters. Values can be  
  changed after create, but may have unintended side effects
  (like data loss).                                         

var.image_name
  Which Openstack image would you like to use for your workspace?

> Enter a value (default: "ubuntu-22.04"): some-other-ubuntu-22.04
var.vm_flavor
  Which Droplet configuration would you like to use?

> Enter a value (default: "c2.d20.r2048"):  c4.d40.r4096

Planning workspace...
✔ Queued [712ms]
✔ Setting up [524ms]
✔ Detecting persistent resources [1630ms]
✔ Cleaning Up [126ms]

...

If y'all are open for a PR I can get that pushed up pretty quick (Haven't run tests yet since I built it in an incomplete dev environment but i'll update/add any necessary tests as part of the PR).

@coadler
Copy link
Contributor

coadler commented Dec 12, 2022

Please do! Feel free to ping me if you'd like help with the tests as well.

@RickyGrassmuck
Copy link
Contributor Author

Running a lint right now and about to push up the changes I made and open a PR. I think an existing test I updated should be sufficient for the change made but will make any recommended changes in the PR if necessary!

@RickyGrassmuck
Copy link
Contributor Author

@coadler PR #5392 submitted, lemme know if I need to make any changes!

coadler pushed a commit that referenced this issue Dec 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli Area: CLI
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants