From 6eb8ec991570e9a644819071a4f6ad57875fc7c2 Mon Sep 17 00:00:00 2001 From: Patrice Ferlet Date: Thu, 5 May 2022 09:08:12 +0200 Subject: [PATCH] Fix problems of new line + add comments --- generator/writers/configmap.go | 1 + generator/writers/deployment.go | 1 + generator/writers/ingress.go | 5 +++-- generator/writers/service.go | 1 + generator/writers/storage.go | 1 + 5 files changed, 7 insertions(+), 2 deletions(-) diff --git a/generator/writers/configmap.go b/generator/writers/configmap.go index d17a889..846dabc 100644 --- a/generator/writers/configmap.go +++ b/generator/writers/configmap.go @@ -7,6 +7,7 @@ import ( "gopkg.in/yaml.v3" ) +// BuildConfigMap writes the configMap. func BuildConfigMap(c interface{}, kind, servicename, name, templatesDir string) { fname := filepath.Join(templatesDir, servicename+"."+name+"."+kind+".yaml") fp, _ := os.Create(fname) diff --git a/generator/writers/deployment.go b/generator/writers/deployment.go index ca09249..7f594ca 100644 --- a/generator/writers/deployment.go +++ b/generator/writers/deployment.go @@ -10,6 +10,7 @@ import ( "gopkg.in/yaml.v3" ) +// BuildDeployment builds a deployment. func BuildDeployment(deployment *helm.Deployment, name, templatesDir string) { kind := "deployment" fname := filepath.Join(templatesDir, name+"."+kind+".yaml") diff --git a/generator/writers/ingress.go b/generator/writers/ingress.go index aab4fab..be7b4bd 100644 --- a/generator/writers/ingress.go +++ b/generator/writers/ingress.go @@ -23,6 +23,7 @@ apiVersion: extensions/v1beta1 {{- end }}` ) +// BuildIngress generates the ingress yaml file with conditions. func BuildIngress(ingress *helm.Ingress, name, templatesDir string) { // Set the backend for 1.18 for _, b := range ingress.Spec.Rules { @@ -63,7 +64,7 @@ func BuildIngress(ingress *helm.Ingress, name, templatesDir string) { n := CountSpaces(l) l = strings.Repeat(" ", n) + versionCondition118 + l + "\n" + - strings.Repeat(" ", n) + "{{- end -}}" + strings.Repeat(" ", n) + "{{- end }}" } if strings.Contains(l, "ingressClassName") { @@ -82,7 +83,7 @@ func BuildIngress(ingress *helm.Ingress, name, templatesDir string) { if !backendHit { l = strings.Repeat(" ", n) + "{{- else }}\n" + l } else { - l = l + "\n" + strings.Repeat(" ", n) + "{{- end }}" + l = l + "\n" + strings.Repeat(" ", n) + "{{- end }}\n" } backendHit = true } diff --git a/generator/writers/service.go b/generator/writers/service.go index 2ba9b82..c898e27 100644 --- a/generator/writers/service.go +++ b/generator/writers/service.go @@ -8,6 +8,7 @@ import ( "gopkg.in/yaml.v3" ) +// BuildService writes the service (external or not). func BuildService(service *helm.Service, name, templatesDir string) { kind := "service" suffix := "" diff --git a/generator/writers/storage.go b/generator/writers/storage.go index aa1593b..ea3617f 100644 --- a/generator/writers/storage.go +++ b/generator/writers/storage.go @@ -8,6 +8,7 @@ import ( "gopkg.in/yaml.v3" ) +// BuildStorage writes the persistentVolumeClaim. func BuildStorage(storage *helm.Storage, name, templatesDir string) { kind := "pvc" name = storage.Metadata.Labels[helm.K+"/component"]