Refactorisation and improvements

- image of container is now splitted in repository and tag (in values
  and deployment). The "tag" is tested in deployment
- add "chart-version" option

Code:

- globalize the PVC generation
- ensure types for environment values
- refactored to make generic the container creation in a deployment
- avoiding race condition on ServiceConfig by using a copy (then a
  pointer of this copy)
This commit is contained in:
2022-05-06 13:42:53 +02:00
parent 2721cb1136
commit 3031f37509
9 changed files with 208 additions and 115 deletions

View File

@@ -2,6 +2,7 @@ package writers
import (
"katenary/helm"
"log"
"os"
"path/filepath"
@@ -14,12 +15,18 @@ func BuildStorage(storage *helm.Storage, name, templatesDir string) {
name = storage.Metadata.Labels[helm.K+"/component"]
pvcname := storage.Metadata.Labels[helm.K+"/pvc-name"]
fname := filepath.Join(templatesDir, name+"-"+pvcname+"."+kind+".yaml")
fp, _ := os.Create(fname)
fp, err := os.Create(fname)
if err != nil {
log.Fatal(err)
}
defer fp.Close()
volname := storage.K8sBase.Metadata.Labels[helm.K+"/pvc-name"]
fp.WriteString("{{ if .Values." + name + ".persistence." + volname + ".enabled }}\n")
enc := yaml.NewEncoder(fp)
enc.SetIndent(IndentSize)
enc.Encode(storage)
if err := enc.Encode(storage); err != nil {
log.Fatal(err)
}
fp.WriteString("{{- end -}}")
}