quintush / helm-unittest

BDD styled unit test framework for Kubernetes Helm charts as a Helm plugin.
MIT License
345 stars 69 forks source link

[question] How can we assert prefixed labels? #176

Closed edmeister closed 1 year ago

edmeister commented 1 year ago

Hi,

I was looking for a way to assert labels or annotations with the prefixed format as is currently recommended in Kubernetes. I tried multiple formats, but the YAML parser seems to be unable to handle this format in a path.

What would you recommend here?

Example:

metadata:
  ...
  labels:
    app.kubernetes.io/name: example
quintush commented 1 year ago

Hello @edmeister,

In some cases you need to escape special characters. The following example shows how you can validate labels. https://github.com/quintush/helm-unittest/blob/c21120fe63a648cb727dfcd85aa6fa320eeaf951/test/data/v3/with-subchart/tests/ingress_test.yaml#L31

Greetings, @quintush

edmeister commented 1 year ago

Thanks for your reply @quintush. I wasn't aware the equal assertion would also work with non-scalar values.