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

yaml: mapping values are not allowed in this context #7

Closed
nik9839 opened this issue Mar 22, 2021 · 6 comments · Fixed by gruntwork-io/terratest#828
Closed

yaml: mapping values are not allowed in this context #7

nik9839 opened this issue Mar 22, 2021 · 6 comments · Fixed by gruntwork-io/terratest#828
Labels
question Further information is requested

Comments

@nik9839
Copy link

nik9839 commented Mar 22, 2021

Getting this when running test.

=== RUN   TestPodTemplateRendersContainerImage
TestPodTemplateRendersContainerImage 2021-03-22T18:10:59+05:30 command.go:87: Running command helm with args [template --set image=nginx:1.15.8 --show-only templates/pod.yaml pod ../charts/minimal-pod]
TestPodTemplateRendersContainerImage 2021-03-22T18:10:59+05:30 command.go:158: WARNING: Kubernetes configuration file is group-readable. This is insecure. Location: /home/nikhil/.kube/config
TestPodTemplateRendersContainerImage 2021-03-22T18:10:59+05:30 command.go:158: WARNING: Kubernetes configuration file is world-readable. This is insecure. Location: /home/nikhil/.kube/config
TestPodTemplateRendersContainerImage 2021-03-22T18:10:59+05:30 command.go:158: ---
TestPodTemplateRendersContainerImage 2021-03-22T18:10:59+05:30 command.go:158: # Source: minimal-pod/templates/pod.yaml
TestPodTemplateRendersContainerImage 2021-03-22T18:10:59+05:30 command.go:158: apiVersion: v1
TestPodTemplateRendersContainerImage 2021-03-22T18:10:59+05:30 command.go:158: kind: Pod
TestPodTemplateRendersContainerImage 2021-03-22T18:10:59+05:30 command.go:158: metadata:
TestPodTemplateRendersContainerImage 2021-03-22T18:10:59+05:30 command.go:158:   name: pod-minimal-pod
TestPodTemplateRendersContainerImage 2021-03-22T18:10:59+05:30 command.go:158:   labels:
TestPodTemplateRendersContainerImage 2021-03-22T18:10:59+05:30 command.go:158:     app.kubernetes.io/name: minimal-pod
TestPodTemplateRendersContainerImage 2021-03-22T18:10:59+05:30 command.go:158:     helm.sh/chart: minimal-pod-0.1.0
TestPodTemplateRendersContainerImage 2021-03-22T18:10:59+05:30 command.go:158:     app.kubernetes.io/instance: pod
TestPodTemplateRendersContainerImage 2021-03-22T18:10:59+05:30 command.go:158:     app.kubernetes.io/managed-by: Helm
TestPodTemplateRendersContainerImage 2021-03-22T18:10:59+05:30 command.go:158: spec:
TestPodTemplateRendersContainerImage 2021-03-22T18:10:59+05:30 command.go:158:   containers:
TestPodTemplateRendersContainerImage 2021-03-22T18:10:59+05:30 command.go:158:     - name: minimal-pod
TestPodTemplateRendersContainerImage 2021-03-22T18:10:59+05:30 command.go:158:       image: "nginx:1.15.8"
TestPodTemplateRendersContainerImage 2021-03-22T18:10:59+05:30 command.go:158:       ports:
TestPodTemplateRendersContainerImage 2021-03-22T18:10:59+05:30 command.go:158:         - name: http
TestPodTemplateRendersContainerImage 2021-03-22T18:10:59+05:30 command.go:158:           containerPort: 80
TestPodTemplateRendersContainerImage 2021-03-22T18:10:59+05:30 command.go:158:           protocol: TCP
    template.go:66: 
        	Error Trace:	template.go:66
        	            				minimal_pod_template_test.go:27
        	Error:      	Received unexpected error:
        	            	yaml: mapping values are not allowed in this context
        	Test:       	TestPodTemplateRendersContainerImage
--- FAIL: TestPodTemplateRendersContainerImage (0.16s)
FAIL
FAIL	github.com/gruntwork-io/terratest-helm-testing-example/test	0.176s
FAIL

Helm version - version.BuildInfo{Version:"v3.3.4", GitCommit:"a61ce5633af99708171414353ed49547cf05013d", GitTreeState:"clean", GoVersion:"go1.14.9"}

Go version - go version go1.16.2 linux/amd64

@brikis98 brikis98 added the question Further information is requested label Mar 24, 2021
@brikis98
Copy link
Member

Can you share your code?

It's hard to guess without that, but solely from the error, it sounds like you may have invalid YAML in pod.yaml. E.g., Extra or missing whitespace somewhere.

@nik9839
Copy link
Author

nik9839 commented Mar 24, 2021

@brikis98 I just cloned this repo and deleted two files which i do not need, no other changes.

Screenshot from 2021-03-24 16-52-52

@yorinasub17
Copy link
Contributor

Ah this is a bug in terratest, where it is returning both stdout and stderr and the warnings are leaking in to the output. As a workaround, you can resolve this by addressing the warnings that the command is returning to you:

WARNING: Kubernetes configuration file is group-readable. This is insecure. Location: /home/nikhil/.kube/config
WARNING: Kubernetes configuration file is world-readable. This is insecure. Location: /home/nikhil/.kube/config

@nik9839
Copy link
Author

nik9839 commented Mar 24, 2021

@yorinasub17 thanks, updating the .kube/config file permission resolved the issue.

@nik9839
Copy link
Author

nik9839 commented Mar 24, 2021

@yorinasub17 should i close the issue or wait till you PR on terratest is approved ?

@yorinasub17
Copy link
Contributor

Thanks for closing the loop! PR in terratest is released and merged so closed issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants