Skip to content

Instantly share code, notes, and snippets.

@jwillker
Created May 8, 2022 22:03
Show Gist options
  • Save jwillker/53fb69ae8709233bb2d78ee0b6a86929 to your computer and use it in GitHub Desktop.
Save jwillker/53fb69ae8709233bb2d78ee0b6a86929 to your computer and use it in GitHub Desktop.
// Render receive helm parameters and render a k8s object
func Render(t *testing.T, helmChartPath, templateFile, release string, values map[string]string, k8sObject interface{}) error {
// Passing values to helm chart.
options := &helm.Options{
SetValues: values,
}
templateFile = fmt.Sprintf("templates/%s", templateFile)
output, err := helm.RenderTemplateE(t, options, helmChartPath, release, []string{templateFile})
if err != nil {
return err
}
// ensure the k8s object is rendered correctly.
err = helm.UnmarshalK8SYamlE(t, output, &k8sObject)
if err != nil {
return err
}
return nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment