From 48f6045cd38310d06d0ac55b341813e2b8d0a91a Mon Sep 17 00:00:00 2001 From: Patrice Ferlet Date: Thu, 21 Nov 2024 11:03:10 +0100 Subject: [PATCH] fix(same-pod): environnment and volume mapping We must ensure that the volume is owned by the container. The environmment configMap wasn't bound. --- generator/deployment.go | 6 +++++- generator/generator.go | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/generator/deployment.go b/generator/deployment.go index d39c8e8..a4dc0bd 100644 --- a/generator/deployment.go +++ b/generator/deployment.go @@ -405,7 +405,11 @@ func (d *Deployment) Yaml() ([]byte, error) { if strings.Contains(volume, "mountPath: ") { spaces = strings.Repeat(" ", utils.CountStartingSpaces(volume)) - varName := d.volumeMap[volumeName] + varName, ok := d.volumeMap[volumeName] + if !ok { + // this case happens when the volume is a "bind" volume comming from a "same-pod" service. + continue + } varName = strings.ReplaceAll(varName, "-", "_") content[line] = spaces + `{{- if .Values.` + serviceName + `.persistence.` + varName + `.enabled }}` + "\n" + volume changing = true diff --git a/generator/generator.go b/generator/generator.go index dc521dd..0ba4746 100644 --- a/generator/generator.go +++ b/generator/generator.go @@ -87,6 +87,7 @@ func Generate(project *types.Project) (*HelmChart, error) { if target, ok := deployments[samepod]; ok { target.AddContainer(*service) target.BindFrom(*service, deployments[service.Name]) + target.SetEnvFrom(*service, appName) delete(deployments, service.Name) } else { log.Printf("service %[1]s is declared as %[2]s, but %[2]s is not defined", service.Name, labels.LabelSamePod)