CircleCI-Public / orb-tools-orb

Various tools for authoring and publishing CircleCI orbs
https://circleci.com/orbs/registry/orb/circleci/orb-tools
MIT License
51 stars 76 forks source link

`orb-tools/pack` fails if boolean parameter's default value is other than `true` or `false` #145

Closed yaningo closed 1 year ago

yaningo commented 2 years ago

Orb version:

11.1.2

What happened:

According to the CircleCI documentation, boolean parameters can have the following values: y yes true on n no false off

However, if a command parameter is declared as a boolean with a default value other than true or false, the "Validating orb" step fails with:

Parameter error: default value of parameter '<parameter_name>' is 'on' (type string): expected type boolean

https://app.circleci.com/pipelines/github/orbiously/openvpn2-orb/53/workflows/b89b1c00-95d6-472b-aa8d-7f7158dcb9b2/jobs/334

Expected behavior:

The "Validating orb" step should pass if the boolean default value is any of: y yes true on n no false off

Additional Information:

Using:

circleci version
0.1.17183+341e493 (homebrew)

And the generated orb.yml contains a string value:

        parameters:
            killswitch:
                default: "on"
                type: boolean

jobs:
build: parameters: killswitch: type: boolean default: on machine: image: ubuntu-2004:202201-02 steps:

  I suspect the issue is caused by the use of "gopkg.in/yaml.v3" in https://github.com/CircleCI-Public/circleci-cli/blob/master/cmd/config.go#L17.

Specifically, as of v3 of the yaml package:

  • YAML 1.1 bools (yes/no, on/off) are supported as long as they are being decoded into a typed bool value. Otherwise they behave as a string. Booleans in YAML 1.2 are true/false only.

(Reference: https://pkg.go.dev/gopkg.in/yaml.v3#readme-compatibility)

Also see https://github.com/CircleCI-Public/circleci-cli/issues/691

KyleTryon commented 1 year ago

Thank you for submitting this. Because this issue seems to be tied to the CLI rather than the orb, I am going to close this issue in this repository. The Issue you created #691 will serve to track this. Thank you.