massdriver-cloud / massdriver-cli

Deprecated. See https://github.com/massdriver-cloud/mass
https://massdriver.cloud
Apache License 2.0
3 stars 2 forks source link

Custom prompts for `mass app/bundle new` #109

Open coryodaniel opened 2 years ago

coryodaniel commented 2 years ago

We should add a prompts.json file to application templates that lets the template developer add additional fields to the prompt for the end user to fill in so we don't have to litter the templates with TODO (put your value here).

We can use JSON Schema to define these, loop through and even use JSON Schema to do rich validation.

The two caveats w/ json schema are:

An example would be for aws-lambda application template... the main.tf file will probably resemble:

module "lambda" {
  source = ".../massdriver-application-aws-lambda"
  # a bunch of fields for the lambda
  runtime = "nodejs900.4"
}

The runtime for lambda will likely not change for a given users application, so it shouldnt be present in their YAML. The user does need the runtime they plan to use though in their terraform.

Using this prompts feature:

mass app new
[x] aws-lambda
Name: foo
Description: does a great foo
Runtime:
[x] Node JS 90000
[ ] Ruby 3x3
[ ] Python 2.3.2.3.2.3.2.3.lol

And this would fill in the templated terraform:

module "lambda" {
  source = ".../massdriver-application-aws-lambda"
  # a bunch of fields for the lambda
  runtime = "<md .Runtime md>"
}