gruntwork-io / boilerplate

A tool for generating files and folders ("boilerplate") from a set of templates
https://www.gruntwork.io
Mozilla Public License 2.0
157 stars 12 forks source link

Introduce validations and variable order #124

Closed zackproser closed 1 year ago

zackproser commented 1 year ago

Description

This PR is intended to be merged to master in lieu of #105, and it is ready for review!

These changes introduce two new features to boilerplate:

Validations

Validations and prompt order are defined in your boilerplate.yml like so:

variables:
  - name: CompanyName
    order: 0
    description: |
      Enter the name of your organization. This will be used to generate a prefix name for every resource.

      Example: gruntwork
    default: ""
    type: string
    validations:
      - required
      - length-5-22
      - alphanumeric

In this example variable definition, we're defining a prompt order of 0, meaning this variable will always be shown to users first. We also define three validations that any user submission for this variable must satisfy. Any user-submissions that do not pass validation will be rejected at runtime with a helpful error message, like so:

bp-validation

TODOs

Read the Gruntwork contribution guidelines.

Release Notes (draft)

Implement variable validations and relative ordering.

Migration Guide

brikis98 commented 1 year ago

Does this replace https://github.com/gruntwork-io/boilerplate/pull/105? Is it ready for review?

zackproser commented 1 year ago

Does this replace #105? Is it ready for review?

This will replace #105, yes! It is not yet ready for review - I want to add a couple tests first, but I'll ping you once I'm ready as I'll need an up-to-speed reviewer.

zackproser commented 1 year ago

@brikis98 Okay, this is ready for review when you have the cycles!

brikis98 commented 1 year ago

I recorded a video while doing this code review in case that's helpful: https://gruntwork-io.slack.com/archives/C01M9MXBNTF/p1666951386005529

zackproser commented 1 year ago

Thanks for review! Going to merge this in now, but will address all your findings in a follow-up PR.