Skip to content

Commit 9f44526

Browse files
dashanjiarttor
authored andcommitted
Update the multiline annotation and use helmify.Values to add the options in the values.yaml
Signed-off-by: dashanji <[email protected]>
1 parent d9daf59 commit 9f44526

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ Usage:
8686
| -version | Print helmify version. | `helmify -version`|
8787
| -crd-dir | Place crds in their own folder per Helm 3 [docs](https://helm.sh/docs/chart_best_practices/custom_resource_definitions/#method-1-let-helm-do-it-for-you). Caveat: CRDs templating is not supported by Helm. | `helmify -crd-dir`|
8888
| -image-pull-secrets| Allows the user to use existing secrets as imagePullSecrets | `helmify -image-pull-secrets`|
89-
89+
| -cert-manager-as-subchart | Allows the user to install cert-manager as a subchart | `helmify -cert-manager-as-subchart`|
9090
## Status
9191
Supported k8s resources:
9292
- Deployment, DaemonSet, StatefulSet

pkg/helm/chart.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func (o output) Create(chartDir, chartName string, crd bool, certManagerAsSubcha
5656
return err
5757
}
5858
}
59-
err = overwriteValuesFile(cDir, values)
59+
err = overwriteValuesFile(cDir, values, certManagerAsSubchart)
6060
if err != nil {
6161
return err
6262
}
@@ -101,14 +101,17 @@ func overwriteTemplateFile(filename, chartDir string, crd bool, templates []helm
101101
return nil
102102
}
103103

104-
func overwriteValuesFile(chartDir string, values helmify.Values) error {
104+
func overwriteValuesFile(chartDir string, values helmify.Values, certManagerAsSubchart bool) error {
105+
if certManagerAsSubchart {
106+
values.Add(true, "cert-manager", "installCRDs")
107+
values.Add(true, "cert-manager", "enabled")
108+
}
105109
res, err := yaml.Marshal(values)
106110
if err != nil {
107111
return errors.Wrap(err, "unable to write marshal values.yaml")
108112
}
109113

110114
file := filepath.Join(chartDir, "values.yaml")
111-
res = append(res, []byte("cert-manager:\n enabled: false\n installCRDs: true")...)
112115
err = ioutil.WriteFile(file, res, 0600)
113116
if err != nil {
114117
return errors.Wrap(err, "unable to write values.yaml")

pkg/helm/init.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,9 +183,14 @@ func createCommonFiles(chartDir, chartName string, crd bool, certManagerAsSubcha
183183

184184
func chartYAML(appName string, certManagerAsSubchart bool) []byte {
185185
chartFile := defaultChartfile
186+
annotatins := `
187+
dependencies:
188+
- name: cert-manager
189+
version: 1.9.1
190+
repository: https://charts.jetstack.io
191+
condition: certManager.enabled`
186192
if certManagerAsSubchart {
187-
chartFile += "\ndependencies:\n - name: cert-manager\n version: 1.9.1\n" +
188-
" repository: https://charts.jetstack.io\n condition: cert-manager.enabled"
193+
chartFile += annotatins
189194
}
190195
return []byte(fmt.Sprintf(chartFile, appName))
191196
}

0 commit comments

Comments
 (0)