Make it possible to mount one file from configMap
This commit is contained in:
@@ -403,12 +403,21 @@ func prepareVolumes(deployment, name string, s *compose.Service, container *helm
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if isCM {
|
if isCM {
|
||||||
|
// check if the volname path points on a file, if so, we need to add subvolume to the interface
|
||||||
|
stat, _ := os.Stat(volname)
|
||||||
|
pointToFile := ""
|
||||||
|
if !stat.IsDir() {
|
||||||
|
pointToFile = filepath.Base(volname)
|
||||||
|
volname = filepath.Dir(volname)
|
||||||
|
}
|
||||||
|
|
||||||
// the volume is a path and it's explicitally asked to be a configmap in labels
|
// the volume is a path and it's explicitally asked to be a configmap in labels
|
||||||
cm := buildCMFromPath(volname)
|
cm := buildCMFromPath(volname)
|
||||||
volname = strings.Replace(volname, "./", "", 1)
|
volname = strings.Replace(volname, "./", "", 1)
|
||||||
volname = strings.ReplaceAll(volname, "/", "-")
|
volname = strings.ReplaceAll(volname, "/", "-")
|
||||||
volname = strings.ReplaceAll(volname, ".", "-")
|
volname = strings.ReplaceAll(volname, ".", "-")
|
||||||
cm.K8sBase.Metadata.Name = RELEASE_NAME + "-" + volname + "-" + name
|
cm.K8sBase.Metadata.Name = RELEASE_NAME + "-" + volname + "-" + name
|
||||||
|
|
||||||
// build a configmap from the volume path
|
// build a configmap from the volume path
|
||||||
volumes = append(volumes, map[string]interface{}{
|
volumes = append(volumes, map[string]interface{}{
|
||||||
"name": volname,
|
"name": volname,
|
||||||
@@ -416,10 +425,18 @@ func prepareVolumes(deployment, name string, s *compose.Service, container *helm
|
|||||||
"name": cm.K8sBase.Metadata.Name,
|
"name": cm.K8sBase.Metadata.Name,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
mountPoints = append(mountPoints, map[string]interface{}{
|
if len(pointToFile) > 0 {
|
||||||
"name": volname,
|
mountPoints = append(mountPoints, map[string]interface{}{
|
||||||
"mountPath": volepath,
|
"name": volname,
|
||||||
})
|
"mountPath": volepath,
|
||||||
|
"subPath": pointToFile,
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
mountPoints = append(mountPoints, map[string]interface{}{
|
||||||
|
"name": volname,
|
||||||
|
"mountPath": volepath,
|
||||||
|
})
|
||||||
|
}
|
||||||
ret <- cm
|
ret <- cm
|
||||||
} else {
|
} else {
|
||||||
// rmove minus sign from volume name
|
// rmove minus sign from volume name
|
||||||
|
Reference in New Issue
Block a user