rancher / hull

Keep your Helm charts afloat with comprehensive testing
Apache License 2.0
4 stars 5 forks source link

Support the ability to generate templates on tests based on a live Kubernetes cluster #2

Open aiyengar2 opened 1 year ago

aiyengar2 commented 1 year ago

Currently, Hull utilizes e.Render instead of e.RenderWithClient in the following code used to generate a template:

https://github.com/aiyengar2/hull/blob/33cf243dca452b3fa1d5d471d6bcd6806e2f4205/pkg/chart/chart.go#L75-L78

As a result, the output of the template that is generated mimics what would be created in a helm template or helm install --dry-run instead of a true helm install (which would support additional functionality like verifying the output from lookup calls).

To support the ability for tests to mimic parsing the template generated during a Helm install instead, we should allow the ability for users to set USE_CLUSTER_FROM_ENV=1, which should populate the client used in this call with the one generated by finding the current KUBECONFIG from the environment (which can be done by leveraging the code here).

This KUBECONFIG should then be used to grab the latest Helm release secret for the given chart, which will contain the information necessary to create a chart.Template off of.