microsoft / PSRule.Rules.CAF

A suite of rules to validate Azure resources against the Cloud Adoption Framework (CAF) using PSRule.
MIT License
62 stars 15 forks source link

PSRule.Rules.CAF version mismatch #130

Open Gordonby opened 1 year ago

Gordonby commented 1 year ago

Description of the issue

Specifying the prerelease flag on the CAF rules results in a version error.

To Reproduce

Ref: https://github.com/Azure/AKS-Construction/actions/runs/4054300944/workflow

      - name: PSRule for CAF
        uses: microsoft/ps-rule@v2.7.0
        continue-on-error: true #Setting this whilst PSRule gets bedded in, in this project
        with:
          modules: 'PSRule.Rules.CAF'
          inputPath: "${{ env.ParamFilePath }}"
          prerelease: true

Error output

Error: The module version '0.4.0-B2208003' for 'PSRule.Rules.CAF' does not match the required version '>=0.3.0'. To continue, first update the module to match the version requirement.
BernieWhite commented 1 year ago

@Gordonby Thanks for reporting the issue. Sorry for the delay in response.

The reason is that the PSRule requires option follows SemVer in a similar behaviour as NPM. A version major.minor.patch constraint won't automatically accept a pre-release version.

There are two approaches you could consider for setting a requires constraint to allow pre-releases:

  1. Include @prerelease or just @pre in the version constraint, which allows any pre-releases newer then 0.3.0. e.g. @pre >=0.3.0.
    • Allows any stable or pre-release version higher or equal to 0.3.0.
  2. Include a secondary constraint that allows pre-releases for v0.4.0. e.g. >=0.3.0 || >=0.4.0-0.
    • The constraint 0.4.0-0 allows any stable version higher or equal to 0.4.0 and pre-releases of 0.4.0 only.

From your question, you probably intend option 1.

The requires option supports the same as the version assertion. Which shows detailed examples of constraint options here: https://microsoft.github.io/PSRule/v2/concepts/PSRule/en-US/about_PSRule_Assert/#version