boilerplate icon indicating copy to clipboard operation
boilerplate copied to clipboard

Parse CLI vars using specified var types rather than YAML defaults

Open ellisonc opened this issue 1 year ago • 2 comments

Describe the bug When parsing inputs on the cli given by --var, boilerplate will use default YAML parsing rules to guess the type rather than using the type provided in the boilerplate.yml file

To Reproduce

Suppose we have a boilerplate.yml file like this:

  - name: AwsLogsAccountId
    order: 4
    description: Enter the AWS account ID for the logs account
    type: string

You would expect to be able to use a command like the following to provide the AWS account ID:

boilerplate ... --var AwsLogsAccountId=1234567890

This will throw an error saying an integer cannot be treated as a string:

ERROR: Value '9.87654321e+08' is not a valid value for variable 'AwsLogsAccountId' with type 'string'.

Expected behavior When type is ambiguous, default to the type specified by the user in the boilerplate.yml file

Additional context Based on an inspection of the code, I suspect this would happen with other yaml types as well, but haven't verified.

As a workaround you can provide the value as a YML string, but this is not expected unless the user knows yaml parsing is being used under the hood:

boilerplate  ... --var AwsLogsAccountId="'1234567890'"

ellisonc avatar Aug 22 '23 16:08 ellisonc