diff options
author | Urvashi Mohnani <umohnani@redhat.com> | 2022-09-01 11:50:19 -0400 |
---|---|---|
committer | Matthew Heon <mheon@redhat.com> | 2022-09-06 15:05:50 -0400 |
commit | 48a02aa1c02ddeffd16b3c19ccf9aa23c482e82a (patch) | |
tree | 2f232a99f0f2a3aa2eac5e698322a8e9a757e0e9 /pkg/specgen/generate | |
parent | 7bb7908efaea76e9497a0c914fb29b0a3cdd5fff (diff) | |
download | podman-48a02aa1c02ddeffd16b3c19ccf9aa23c482e82a.tar.gz podman-48a02aa1c02ddeffd16b3c19ccf9aa23c482e82a.tar.bz2 podman-48a02aa1c02ddeffd16b3c19ccf9aa23c482e82a.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/generate')
-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 454a1e1d0..d055ec999 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{ |