fix(volume) File from project root failed
All checks were successful
Go-Tests / tests (pull_request) Successful in 1m47s
Go-Tests / sonar (pull_request) Successful in 48s
Go-Tests / tests (push) Successful in 1m37s
Go-Tests / sonar (push) Successful in 46s

When mounting one file from the root of the project (e.g. ./file.txt),
the volume name is empty. In this case, we generate the volume name from
the subpath.
This commit is contained in:
2025-09-14 23:23:11 +02:00
parent 8358b068b3
commit 03b4d5c714
3 changed files with 32 additions and 3 deletions

View File

@@ -278,6 +278,7 @@ func addStaticVolumes(deployments map[string]*Deployment, service types.ServiceC
if y, err = config.configMap.Yaml(); err != nil {
log.Fatal(err)
}
// add the configmap to the chart
d.chart.Templates[config.configMap.Filename()] = &ChartTemplate{
Content: y,
@@ -285,6 +286,10 @@ func addStaticVolumes(deployments map[string]*Deployment, service types.ServiceC
}
// add the moint path to the container
for _, m := range config.mountPath {
// volumeName can be empty, in this case we generate a name
if volumeName == "" {
volumeName = utils.PathToName(m.subPath)
}
container.VolumeMounts = append(container.VolumeMounts, corev1.VolumeMount{
Name: utils.PathToName(volumeName),
MountPath: m.mountPath,