From 069cddcdc0c4c71fca8c05099d897e16f37b5af9 Mon Sep 17 00:00:00 2001 From: Patrice Ferlet Date: Tue, 30 Nov 2021 12:09:07 +0100 Subject: [PATCH] Fix ingress --- generator/main.go | 4 ++-- helm/ingress.go | 4 ++-- main.go | 11 +++++++---- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/generator/main.go b/generator/main.go index f09fd90..d31e8f1 100644 --- a/generator/main.go +++ b/generator/main.go @@ -17,7 +17,7 @@ var serviceWaiters = make(map[string][]chan int) var locker = &sync.Mutex{} var serviceTick = make(chan int, 0) -var Ingresses = make([]*helm.Ingress, 0) +var Ingresses = make(map[string]*helm.Ingress, 0) var Values = make(map[string]map[string]interface{}) var DependScript = ` @@ -168,7 +168,7 @@ func createIngress(name string, port int, s compose.Service) { } locker.Lock() - Ingresses = append(Ingresses, ingress) + Ingresses[name] = ingress locker.Unlock() } diff --git a/helm/ingress.go b/helm/ingress.go index 640d259..243c3d8 100644 --- a/helm/ingress.go +++ b/helm/ingress.go @@ -1,8 +1,8 @@ package helm type Ingress struct { - *K8sBase - Spec IngressSpec + *K8sBase `yaml:",inline"` + Spec IngressSpec } func NewIngress(name string) *Ingress { diff --git a/main.go b/main.go index f1cddec..f0cb7ce 100644 --- a/main.go +++ b/main.go @@ -2,12 +2,12 @@ package main import ( "flag" - "fmt" "helm-compose/compose" "helm-compose/generator" "helm-compose/helm" "os" "path/filepath" + "strings" "sync" "gopkg.in/yaml.v3" @@ -45,6 +45,7 @@ func main() { for n, f := range files { for _, c := range f { kind := c.(helm.Kinded).Get() + kind = strings.ToLower(kind) fname := filepath.Join(templatesDir, n+"."+kind+".yaml") fp, _ := os.Create(fname) enc := yaml.NewEncoder(fp) @@ -54,12 +55,14 @@ func main() { } } - for _, ing := range generator.Ingresses { + for name, ing := range generator.Ingresses { - fmt.Println("---") - enc := yaml.NewEncoder(os.Stdout) + fname := filepath.Join(templatesDir, name+".ingress.yaml") + fp, _ := os.Create(fname) + enc := yaml.NewEncoder(fp) enc.SetIndent(2) enc.Encode(ing) + fp.Close() } enc := yaml.NewEncoder(os.Stdout)