arttor / helmify

Creates Helm chart from Kubernetes yaml
MIT License
1.48k stars 136 forks source link

Fixed the Indent length for CronJob #137

Closed chriskery closed 8 months ago

chriskery commented 8 months ago

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
arttor commented 8 months ago

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

chriskery commented 8 months ago

@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