quintush / helm-unittest

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

Is it possible to specify Chart.Version? #67

Closed torstenwalter closed 3 years ago

torstenwalter commented 3 years ago

Background: I want to verify default labels on Kubernetes resources. They also contain "helm.sh/chart": "{{ .Chart.Name }}-{{ .Chart.Version }}" which contains the name of the chart and it's version.

I could write a test like the one below which checks for the current chart version:

suite: test labels
release:
  name: my-release
  namespace: my-namespace
tests:
- it: deployment labels
  set:
    Release.
  template: jenkins-master-deployment.yaml
  asserts:
  - equal:
      path: metadata.labels
      value:
        app.kubernetes.io/component: jenkins-master
        app.kubernetes.io/instance: my-release
        app.kubernetes.io/managed-by: Tiller
        app.kubernetes.io/name: jenkins
        helm.sh/chart: jenkins-2.8.0

That would not be very practical as the tests would need to be adjusted for every version of the chart.

I could of course check each label individually, but that would be quite some repetition. Is it somehow possible to override the chart version in a unit test to provide a fixed value or is there a better approach?

quintush commented 3 years ago

Hello @torstenwalter,

Thanks for the suggestion. I will look info this to see if the chart version van be overridden, similar as the release-name and release-namespace.

Greetings, @quintush