Data Driven Tests/Rules #2466
-
Pester supports a feature called Data Driven Tests. Can I use something similar with PSRule? Use case: Ideally I don't want hardcoded values in rules due to configuration differences between environments. e.g. I want to assert that a virtual network address space has been configured correctly. The CIDR value may well be different between say PreProd and Prod environments. What is the best/recommended way to setup/configure rules in such a case? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
Hi @paulmccrady, PSRule supports configuration. You would set a configuration value which can be done in a number of ways but via configuration:
VNET_CIDR: 10.1.1.0/24 https://microsoft.github.io/PSRule/v2/concepts/PSRule/en-US/about_PSRule_Options/#configuration Then you would use this configuration in the rule using the For example: PowerShell rules: YAML rules: If you have an example maybe I can provide an alternative suggestion. |
Beta Was this translation helpful? Give feedback.
-
Also, in your suggestion above, can you have a ps_rule.yaml for say preprod and another for prod? we work with mono repos sometimes where the config for all environments is contained in the same repo and during a pipeline execution, a user would select the target environment (preprod or prod for example). the appropriate config is then loaded by the pipeline itself. |
Beta Was this translation helpful? Give feedback.
@paulmccrady you would need to include all the configuration in each file.
We are considering merging options files for PSRule v3. Which is a future release.