From 13f74c9e4ddfee4949e95d87772f8bbdff3e67f9 Mon Sep 17 00:00:00 2001 From: Patrice Ferlet Date: Thu, 5 May 2022 08:59:31 +0200 Subject: [PATCH] Optim --- generator/writers/ingress.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/generator/writers/ingress.go b/generator/writers/ingress.go index 9c00f89..aab4fab 100644 --- a/generator/writers/ingress.go +++ b/generator/writers/ingress.go @@ -42,7 +42,12 @@ func BuildIngress(ingress *helm.Ingress, name, templatesDir string) { enc.Encode(ingress) buffer.WriteString("{{- end -}}") - fp, _ := os.Create(fname) + fp, err := os.Create(fname) + if err != nil { + panic(err) + } + defer fp.Close() + content := string(buffer.Bytes()) lines := strings.Split(content, "\n") @@ -67,7 +72,7 @@ func BuildIngress(ingress *helm.Ingress, name, templatesDir string) { l = ` ` + cond + l + "\n" + ` {{- end }}` } - // manage the backend format following the Kubernetes 1.18-0 version or higher + // manage the backend format following the Kubernetes 1.19-0 version or higher if strings.Contains(l, "service:") { n := CountSpaces(l) l = strings.Repeat(" ", n) + versionCondition119 + l @@ -81,9 +86,6 @@ func BuildIngress(ingress *helm.Ingress, name, templatesDir string) { } backendHit = true } - fp.WriteString(l + "\n") } - - fp.Close() }