Refactorisation to writers in generator package

This commit is contained in:
2021-12-05 10:13:11 +01:00
parent fe2a655796
commit df60c2c866
7 changed files with 254 additions and 168 deletions

View File

@@ -0,0 +1,21 @@
package writers
import (
"katenary/helm"
"os"
"path/filepath"
"gopkg.in/yaml.v3"
)
func BuildStorage(storage *helm.Storage, name, templatesDir string) {
kind := "pvc"
fname := filepath.Join(templatesDir, name+"."+kind+".yaml")
fp, _ := os.Create(fname)
volname := storage.K8sBase.Metadata.Labels[helm.K+"/pvc-name"]
fp.WriteString("{{ if .Values." + name + ".persistence." + volname + ".enabled }}\n")
enc := yaml.NewEncoder(fp)
enc.SetIndent(2)
enc.Encode(storage)
fp.WriteString("{{- end -}}")
}