Merge pull request #21084 from ygalblum/kube-generate-bind-mount-annotation

Kube Generate - check options in bind-mount-options exist before accessing
This commit is contained in:
openshift-merge-bot[bot]
2024-01-02 08:27:42 +00:00
committed by GitHub

View File

@ -488,7 +488,7 @@ func ToSpecGen(ctx context.Context, opts *CtrSpecGenOptions) (*specgen.SpecGener
// Make sure the z/Z option is not already there (from editing the YAML)
if k == define.BindMountPrefix {
lastIndex := strings.LastIndex(v, ":")
if v[:lastIndex] == volumeSource.Source && !cutil.StringInSlice("z", options) && !cutil.StringInSlice("Z", options) {
if lastIndex != -1 && v[:lastIndex] == volumeSource.Source && !cutil.StringInSlice("z", options) && !cutil.StringInSlice("Z", options) {
options = append(options, v[lastIndex+1:])
}
}