Skip to content

Validate Chart version is set and supported in AdmissionWebhook

Summary

Uses the AdmissionWebhook to validate that:

  • The chart version is set during create and update
  • The chart version is supported

It achieves this by moving some Helm helper functions into the helm package so they can be imported by the api package without circular dependency problems.

Related to #321 (closed)

References

Testing

Not setting a chart version

Unset spec.chart.version:

$ time kubectl apply -f mygitlab.yaml -n gitlab-system
The gitlab "gitlab" is invalid: spec.chart.version: Invalid value: "": chart version must be configured
kubectl apply -f mygitlab.yaml -n gitlab-system  0.31s user 0.19s system 125% cpu 0.400 total

Using an unsupported chart version

Set spec.chart.version=1.1.1, or any unsupported verison (i.e. not listed in CHART_VERSIONS):

$ time kubectl apply -f mygitlab.yaml -n gitlab-system
The gitlab "gitlab" is invalid: spec.chart.version: Invalid value: "1.1.1": chart version 1.1.1 not supported; please use one of the following: 5.6.1, 5.5.2, 5.4.4
kubectl apply -f mygitlab.yaml -n gitlab-system  0.30s user 0.19s system 120% cpu 0.409 total

To do

Edited by Mitchell Nielsen

Merge request reports

Loading