diff options
author | Urvashi Mohnani <umohnani@redhat.com> | 2022-09-01 11:50:19 -0400 |
---|---|---|
committer | Urvashi Mohnani <umohnani@redhat.com> | 2022-09-01 11:51:46 -0400 |
commit | 4a1acccf965362eb315b38f9b2cb35a8564aa173 (patch) | |
tree | d168dba28517086885046826a16c8fba78d15e07 /pkg/specgen | |
parent | 0085fbb488eec30e71e6cced6a06dbdb134e32a6 (diff) | |
download | podman-4a1acccf965362eb315b38f9b2cb35a8564aa173.tar.gz podman-4a1acccf965362eb315b38f9b2cb35a8564aa173.tar.bz2 podman-4a1acccf965362eb315b38f9b2cb35a8564aa173.zip |
Fix bind-mount-option annotation in gen/play kube
The format used for setting the bind-mount-options annotations
in the kube yaml was incorrect and caused k8s to throw an error
when trying to play the generated kube yaml.
Fix the annotation format to match the rules of k8s.
Signed-off-by: Urvashi Mohnani <umohnani@redhat.com>
Diffstat (limited to 'pkg/specgen')
-rw-r--r-- | pkg/specgen/generate/kube/kube.go | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/pkg/specgen/generate/kube/kube.go b/pkg/specgen/generate/kube/kube.go index 375b719d3..5862d3f1c 100644 --- a/pkg/specgen/generate/kube/kube.go +++ b/pkg/specgen/generate/kube/kube.go @@ -357,8 +357,11 @@ func ToSpecGen(ctx context.Context, opts *CtrSpecGenOptions) (*specgen.SpecGener // a selinux mount option exists for it for k, v := range opts.Annotations { // Make sure the z/Z option is not already there (from editing the YAML) - if strings.Replace(k, define.BindMountPrefix, "", 1) == volumeSource.Source && !cutil.StringInSlice("z", options) && !cutil.StringInSlice("Z", options) { - options = append(options, v) + if k == define.BindMountPrefix { + lastIndex := strings.LastIndex(v, ":") + if v[:lastIndex] == volumeSource.Source && !cutil.StringInSlice("z", options) && !cutil.StringInSlice("Z", options) { + options = append(options, v[lastIndex+1:]) + } } } mount := spec.Mount{ |