Skip to content
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

Parse CLI vars using specified var types rather than YAML defaults #137

Open
ellisonc opened this issue Aug 22, 2023 · 2 comments
Open

Parse CLI vars using specified var types rather than YAML defaults #137

ellisonc opened this issue Aug 22, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@ellisonc
Copy link

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'"
@ozbillwang
Copy link

ozbillwang commented Jan 29, 2024

Appreciate it, @ellisonc The workaround you suggested is effective, even it starts with "0"

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

@jasonyoung-pearl
Copy link
Contributor

Same issue here:

  - name: AwsVersion
    description: Version of the AWS provider required in the module
    default: "5.0"
boilerplate ... --var AwsVersion='5.0'
# results in:
ERROR: Value '5' is not a valid value for variable 'AwsVersion' with type 'string'.

This workaround fixes it:

boilerplate ... --var AwsVersion="'5.0'"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants