Configuration for YAML/ JSON based rules
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 I can probably help with this one. Was thinking configuration could be another comparison property like field, name, type, source we could introduce.
@ArmaanMcleod Thanks. Agreed.
@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.
@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.
This should be addressed by initial function support.