fix(same-pod): environnment and volume mapping

We must ensure that the volume is owned by the container.
The environmment configMap wasn't bound.
This commit is contained in:
2024-11-21 11:03:10 +01:00
parent af8dabba85
commit 48f6045cd3
2 changed files with 6 additions and 1 deletions

View File

@@ -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

View File

@@ -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)