Open UncleIS opened 4 years ago
Hello @UncleIS,
Sorry for the late response.
I tried your case and I think this is the feature you want ;
Feature: test feature
Scenario Outline: Check for Environment Variables
Given I have kubernetes_deployment defined
Then it must have spec
And it must have template
And it must have spec
And it must have container
And it must have env
When it has <key>
Then its <key> must be <value>
Examples:
| key | value |
| name | DUMMY_VAR0 |
| name | DUMMY_VAR1 |
| name | DUMMY_VAR2 |
| name | DUMMY_VAR3 |
| name | DUMMY_VAR4 |
Let me know if this is working for you.
By the way this is the result I got ;
| key | value |
Failure: Can not find DUMMY_VAR0 in name property of kubernetes_deployment.app.
Failure: Can not find DUMMY_VAR0 in name property of kubernetes_deployment.app.
| name | DUMMY_VAR0 |
| name | DUMMY_VAR1 |
| name | DUMMY_VAR2 |
| name | DUMMY_VAR3 |
Failure: Can not find DUMMY_VAR4 in name property of kubernetes_deployment.app.
Failure: Can not find DUMMY_VAR4 in name property of kubernetes_deployment.app.
| name | DUMMY_VAR4 |
Hi and thanks for looking into that!
What about matching the value (not only the name) of the variable to a regular expression
Meaning, that ideally it would be nice to have something like this:
...
Then its name must be <name>
And its value must match the "<regex>" regex
Examples:
|name|regex|
|DUMMY_VAR0|demoapp|
|DUMMY_VAR1|^[0-9]+$|
...
The problem for me is grasping the syntax of how ensure that we do not only have a variable that has a particular name and, possibly, another variable that matches a particular value, but how to ensure that a variable has both name and value matching the requirements of a particular example row.
Btw, in the example that I provided DUMMY_VAR4 is absent indeed, but DUMMY_VAR0 is in place.
Hi and thanks for an amazing tool.
Question : We are actively using Terraform for deploying applications to Kubernetes and would like to check these for compliance matters. As an example, we need to check the presence of a number of environment variables and check that the value of each of them matches a particular regex.
Here is an example resource definition:
We would like to check that:
It is clear that a scenario outline is needed for this, but not exactly clear how to write a rule that would do proper checks.
Thank you for any input!