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

PSRule.Rules.CAF version mismatch #130

Open
Gordonby opened this issue Jan 31, 2023 · 1 comment
Open

PSRule.Rules.CAF version mismatch #130

Gordonby opened this issue Jan 31, 2023 · 1 comment

Comments

@Gordonby
Copy link

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/[email protected]
        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
Copy link
Member

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants