Mount executables with required mode

This commit is contained in:
Prathamesh Musale 2025-11-27 14:52:56 +05:30
parent 408cd36ad3
commit 83fe6f7cb3

View File

@ -347,6 +347,10 @@ func (k *Kubernetes) IntiConfigMapFromFileOrDir(name, cmName, filePath string, s
configMap.Annotations = map[string]string{
"use-subpath": "true",
}
// Check if the file is executable and store that info
if mode&0111 != 0 { // Check if any execute bit is set
configMap.Annotations["executable"] = "true"
}
}
return configMap, nil
@ -1154,6 +1158,13 @@ func (k *Kubernetes) ConfigEmptyVolumeSource(key string) *api.VolumeSource {
func (k *Kubernetes) ConfigConfigMapVolumeSource(cmName string, targetPath string, cm *api.ConfigMap) *api.VolumeSource {
s := api.ConfigMapVolumeSource{}
s.Name = cmName
// Set default mode to 0755 if the file is executable
if cm.Annotations != nil && cm.Annotations["executable"] == "true" {
mode := int32(0755)
s.DefaultMode = &mode
}
if useSubPathMount(cm) {
var keys []string
for k := range cm.Data {