Fix names + color activation

This commit is contained in:
2021-12-02 16:07:15 +01:00
parent b894de6232
commit a292170a63
4 changed files with 42 additions and 3 deletions

14
main.go
View File

@@ -9,6 +9,7 @@ import (
"katenary/helm"
"os"
"path/filepath"
"regexp"
"strings"
"gopkg.in/yaml.v3"
@@ -20,6 +21,8 @@ var AppVersion = "0.0.1"
var Version = "master"
var ChartsDir = "chart"
var PrefixRE = regexp.MustCompile(`\{\{.*\}\}-?`)
func main() {
flag.StringVar(&ChartsDir, "chart-dir", ChartsDir, "set the chart directory")
flag.StringVar(&ComposeFile, "compose", ComposeFile, "set the compose file to parse")
@@ -163,6 +166,17 @@ func main() {
}
fp.Close()
case *helm.ConfigMap, *helm.Secret:
// there could be several files, so let's force the filename
name := c.(helm.Named).Name()
name = PrefixRE.ReplaceAllString(name, "")
fname := filepath.Join(templatesDir, n+"."+name+"."+kind+".yaml")
fp, _ := os.Create(fname)
enc := yaml.NewEncoder(fp)
enc.SetIndent(2)
enc.Encode(c)
fp.Close()
default:
fname := filepath.Join(templatesDir, n+"."+kind+".yaml")
fp, _ := os.Create(fname)