summaryrefslogtreecommitdiff
path: root/pkg/specgen/generate/kube/kube.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2021-12-03 14:54:47 +0100
committerGitHub <noreply@github.com>2021-12-03 14:54:47 +0100
commitdd109daa45bafc85487aa2e627202d23b5c76021 (patch)
treeb627ec36853c7cf40b5202c506c367f332c4d31b /pkg/specgen/generate/kube/kube.go
parent999fe0d89355498c1bc77efb8dfc50c5f0bb0efa (diff)
parent7d331d35ddf5e511bd474505b675191d3f949dc0 (diff)
downloadpodman-dd109daa45bafc85487aa2e627202d23b5c76021.tar.gz
podman-dd109daa45bafc85487aa2e627202d23b5c76021.tar.bz2
podman-dd109daa45bafc85487aa2e627202d23b5c76021.zip
Merge pull request #12440 from umohnani8/cm
Add support for configmap volumes to play kube
Diffstat (limited to 'pkg/specgen/generate/kube/kube.go')
-rw-r--r--pkg/specgen/generate/kube/kube.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/pkg/specgen/generate/kube/kube.go b/pkg/specgen/generate/kube/kube.go
index c502a6e62..6d9f598c9 100644
--- a/pkg/specgen/generate/kube/kube.go
+++ b/pkg/specgen/generate/kube/kube.go
@@ -310,6 +310,11 @@ func ToSpecGen(ctx context.Context, opts *CtrSpecGenOptions) (*specgen.SpecGener
if !exists {
return nil, errors.Errorf("Volume mount %s specified for container but not configured in volumes", volume.Name)
}
+ // Skip if the volume is optional. This means that a configmap for a configmap volume was not found but it was
+ // optional so we can move on without throwing an error
+ if exists && volumeSource.Optional {
+ continue
+ }
dest, options, err := parseMountPath(volume.MountPath, volume.ReadOnly)
if err != nil {
@@ -341,6 +346,13 @@ func ToSpecGen(ctx context.Context, opts *CtrSpecGenOptions) (*specgen.SpecGener
Options: options,
}
s.Volumes = append(s.Volumes, &namedVolume)
+ case KubeVolumeTypeConfigMap:
+ cmVolume := specgen.NamedVolume{
+ Dest: volume.MountPath,
+ Name: volumeSource.Source,
+ Options: options,
+ }
+ s.Volumes = append(s.Volumes, &cmVolume)
default:
return nil, errors.Errorf("Unsupported volume source type")
}