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

Configuration for YAML/ JSON based rules #1016

Closed
BernieWhite opened this issue Mar 20, 2022 · 5 comments · Fixed by #1228
Closed

Configuration for YAML/ JSON based rules #1016

BernieWhite opened this issue Mar 20, 2022 · 5 comments · Fixed by #1228
Assignees
Labels
enhancement New feature or request feature: language Issues that affect language such keywords and variables
Milestone

Comments

@BernieWhite
Copy link
Member

BernieWhite commented Mar 20, 2022

Currently PowerShell-based rules can use configuration values from options.

This is currently not supported for YAML/ JSON rules, we should add this feature.

Related to discussion Azure/PSRule.Rules.Azure#1314

May be able to work into: #1033

@BernieWhite BernieWhite added enhancement New feature or request feature: language Issues that affect language such keywords and variables labels Mar 20, 2022
@ArmaanMcleod ArmaanMcleod self-assigned this Jun 19, 2022
@ArmaanMcleod
Copy link
Contributor

@BernieWhite I can probably help with this one. Was thinking configuration could be another comparison property like field, name, type, source we could introduce.

@BernieWhite
Copy link
Member Author

@ArmaanMcleod Thanks. Agreed.

@ArmaanMcleod
Copy link
Contributor

ArmaanMcleod commented Jun 26, 2022

@BernieWhite If we had a configuration defined like below:

configuration:
  allowedBusinessUnits:
  - 'IT Operations'
  - 'Finance'
  - 'HR'

And a YAML rule

---
# Synopsis: A YAML rule for testing.
apiVersion: github.com/microsoft/PSRule/v1
kind: Rule
metadata:
  name: RuleYamlTagConfig
spec:
  condition:
    allOf:
    - field: 'tags.businessUnit'
      exists: true
    - field: 'tags.businessUnit'
      in:
        configuration: 'allowedBusinessUnits'

How would this work with the existing schema? Since in would expect an array of values to compare against.

Or would we need to convert this to an array of values:

- field: 'tags.businessUnit'
  in:
  - configuration: 'allowedBusinessUnits'

Probably need to find a consistent way to doing this for all the expressions.

@BernieWhite
Copy link
Member Author

@ArmaanMcleod I was thinking something like this:

- field: 'tags.businessUnit'
  in:
    $:
      configuration: 'allowedBusinessUnits'

It should be easy to update the schema to support all the advanced use cases for complex function support through a $ object.

@BernieWhite
Copy link
Member Author

This should be addressed by initial function support.

@BernieWhite BernieWhite mentioned this issue Aug 29, 2022
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request feature: language Issues that affect language such keywords and variables
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants