Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include binaryData when mounting a configmap via subpath volumeMounts #1156

Merged
merged 2 commits into from
Jul 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion pkg/provision/automount/configmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,18 @@ func getAutomountConfigmap(mountPath, mountAs string, accessMode *int32, configm
automount.EnvFromSource = []corev1.EnvFromSource{envFromSource}
case constants.DevWorkspaceMountAsSubpath:
var volumeMounts []corev1.VolumeMount
volumeName := common.AutoMountConfigMapVolumeName(configmap.Name)
for secretKey := range configmap.Data {
volumeMounts = append(volumeMounts, corev1.VolumeMount{
Name: common.AutoMountConfigMapVolumeName(configmap.Name),
Name: volumeName,
ReadOnly: true,
MountPath: path.Join(mountPath, secretKey),
SubPath: secretKey,
})
}
for secretKey := range configmap.BinaryData {
volumeMounts = append(volumeMounts, corev1.VolumeMount{
Name: volumeName,
ReadOnly: true,
MountPath: path.Join(mountPath, secretKey),
SubPath: secretKey,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Includes configmap's binaryData field when provisioning

input:
configmaps:
-
apiVersion: v1
kind: ConfigMap
metadata:
name: test-subpath-configmap
labels:
controller.devfile.io/mount-to-devworkspace: "true"
controller.devfile.io/watch-configmap: 'true'
annotations:
controller.devfile.io/mount-as: subpath
controller.devfile.io/mount-path: /tmp/configmap/subpath
data:
configmap-key: "This is secret"
configmap-key-2: "This is also secret I guess"
binaryData:
binary-key: aGVsbG8K # "hello"

output:
volumes:
- name: test-subpath-configmap
configmap:
name: test-subpath-configmap
defaultMode: 0640
volumeMounts:
- name: test-subpath-configmap
readOnly: true
mountPath: /tmp/configmap/subpath/configmap-key
subpath: configmap-key
- name: test-subpath-configmap
readOnly: true
mountPath: /tmp/configmap/subpath/configmap-key-2
subpath: configmap-key-2
- name: test-subpath-configmap
readOnly: true
mountPath: /tmp/configmap/subpath/binary-key
subpath: binary-key
Loading