kudobuilder / kuttl

KUbernetes Test TooL (kuttl)
https://kuttl.dev
Apache License 2.0
672 stars 86 forks source link

Partial string matching on resource values? #506

Open diranged opened 7 months ago

diranged commented 7 months ago

What would you like to be added: I found it pretty surprising that I couldn't do partial string matching (regex or wildcard) on the values in created resources.

Why is this needed: When working with custom resources like XRDs in Crossplane, I find it difficult to validate certain kinds of dynamic resources because they fundamentally change the return values.. for example, verifying that my Role resource has a status.roleArn field that matches arn:aws:iam:.... The role ARN changes on every test, but fundamentally my goal is to verify that a value was put in there and that it's not empty.

porridge commented 7 months ago

See also https://github.com/kudobuilder/kuttl/issues/224 and https://github.com/kudobuilder/kuttl/issues/70

The closest thing possible right now is to use a TestAssert with a command that does some kind of templating/substitution (if the value you're looking for is predictable at all) and runs a nested kuttl assert.

https://github.com/kudobuilder/kuttl/pull/387 might make this easier but there are no plans to support regexes. You might want to take a look at https://github.com/kyverno/chainsaw

eddycharly commented 7 months ago

Thanks @porridge for the mention!

https://github.com/kyverno/chainsaw supports wildcard matching (and regexes too).