Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Helm chart testing allows duplicate metadata labels #1361

Open
Mo0rBy opened this issue Oct 26, 2023 · 0 comments
Open

Helm chart testing allows duplicate metadata labels #1361

Mo0rBy opened this issue Oct 26, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@Mo0rBy
Copy link

Mo0rBy commented Oct 26, 2023

Describe the bug
I accidentally had a duplicate label in my deployment.yaml template and TerraTest was still able to unmarshal it into a k8s Deployment struct. Because of this, my template tests passed and this chart was deployed into my cluster, where the chart was not able to install. Should this be allowed?

One of the really useful features of unmarshaling into a k8s struct means that the template is tested to see if kubernetes can actually read the template and can use it as a k8s object. Here is the console output of Terratest showing this duplicate label and that it was unmarshaled with no errors:
Screenshot 2023-10-26 at 10 14 47

And here is my k9s output showing that Helm is unable to install the chart due to the duplicate label:
Screenshot 2023-10-26 at 10 20 17

To Reproduce
Create a deployment.yaml template with a duplicate mapping in the spec.template.metadata.labels section.
Use TerraTest's helm.UnmarshalK8SYaml() function to unmarshal the template into a k8s deployment struct.
Deploy the chart to a cluster and see the installation fail due to duplicate key.

Here is a snippet of my render template and unmarshal steps:

BeforeAll(func() {
	options := &helm.Options{
		ValuesFiles: []string{"values/required.yaml"},
	}

	renderedOutput := helm.RenderTemplate(GinkgoT(), options, helmChartPath, microService, []string{"templates/deployment.yaml"})
	helm.UnmarshalK8SYaml(GinkgoT(), renderedOutput, &deployment)
})

Expected behavior
I would expect the helm.UnmarshalK8SYaml() to result in a failure due to the duplicate key mapping in the deployment.yaml template as this is what happens when the Helm chart is deployed into a cluster.

Nice to have

  • [ x ] Terminal output
  • [ x ] Screenshots

Versions

  • Terratest version: v0.43.13
  • Environment details A custom Linux ci-build-tools image + M1 MacOS Ventura 13.6

Additional context
Add any other context about the problem here.

@Mo0rBy Mo0rBy added the bug Something isn't working label Oct 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant