Skip to content

Conversation

@chriskery
Copy link
Contributor

What did I change:

Change CronJob indent to 12 .

detailed:

If I put args in the CronJob like below:

apiVersion: batch/v1
kind: CronJob
metadata:
  name: cron-job
spec:
  schedule: "* * * * *"
  jobTemplate:
    spec:
      template:
        spec:
          containers:
......
              args:
              - --leader-elect

And run pkg/app/app_e2e_test.go, an error occurs:

  app_e2e_test.go:58: 
        	Error Trace:	/Users/yuewenchen/GolandProjects/helmify/pkg/app/app_e2e_test.go:58
        	Error:      	Received unexpected error:
        	            	error converting YAML to JSON: yaml: line 17: did not find expected key
        	            	unable to parse YAML
        	            	helm.sh/helm/v3/pkg/lint/rules.validateYamlContent
        	            		/Users/yuewenchen/go/pkg/mod/helm.sh/helm/v3@v3.11.2/pkg/lint/rules/template.go:212
        	            	helm.sh/helm/v3/pkg/lint/rules.Templates
        	            		/Users/yuewenchen/go/pkg/mod/helm.sh/helm/v3@v3.11.2/pkg/lint/rules/template.go:146
        	            	helm.sh/helm/v3/pkg/lint.All
        	            		/Users/yuewenchen/go/pkg/mod/helm.sh/helm/v3@v3.11.2/pkg/lint/lint.go:34
        	            	helm.sh/helm/v3/pkg/action.lintChart
        	            		/Users/yuewenchen/go/pkg/mod/helm.sh/helm/v3@v3.11.2/pkg/action/lint.go:128
        	            	helm.sh/helm/v3/pkg/action.(*Lint).Run
        	            		/Users/yuewenchen/go/pkg/mod/helm.sh/helm/v3@v3.11.2/pkg/action/lint.go:62
        	            	github.com/arttor/helmify/pkg/app.TestApp
        	            		/Users/yuewenchen/GolandProjects/helmify/pkg/app/app_e2e_test.go:56
        	            	testing.tRunner
        	            		/Users/yuewenchen/go/sdk/go1.21.1/src/testing/testing.go:1595
        	            	runtime.goexit
        	            		/Users/yuewenchen/go/sdk/go1.21.1/src/runtime/asm_amd64.s:1650
        	Test:       	TestApp
--- FAIL: TestApp (0.06s)

If we checks the outputs of helm, we can see that the problem is caused by incorrect args indentation :

> helm template  app . --debug
---
# Source: app/templates/cron-job.yaml
apiVersion: batch/v1
kind: CronJob
spec:
  jobTemplate:
    spec:
      template:
        spec:
          containers:
          - args:
        - --leader-elect

@chriskery chriskery changed the title Fixed the Indent length for CronJob which has args Fixed the Indent length for CronJob Mar 22, 2024
@arttor
Copy link
Owner

arttor commented Mar 24, 2024

@chriskery thank you for contribution. Is similar problem already tackled in #135? PR is in review and waits response from contributor.

@chriskery
Copy link
Contributor Author

@chriskery thank you for contribution. Is similar problem already tackled in #135? PR is in review and waits response from contributor.

Ok, I see it. Thanks for replying

@chriskery chriskery closed this Mar 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants