Skip to content
Merged
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
26 changes: 1 addition & 25 deletions pkg/apis/deviceplugin/v1/qatdeviceplugin_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
package v1

import (
"strings"

"github.com/pkg/errors"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/version"
Expand Down Expand Up @@ -88,27 +86,5 @@ func (r *QatDevicePlugin) ValidateDelete() error {
}

func (r *QatDevicePlugin) validatePlugin() error {
parts := strings.SplitN(r.Spec.Image, ":", 2)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
parts := strings.SplitN(r.Spec.Image, ":", 2)
return validatePluginImage(r.Spec.Image, "intel-qat-plugin", qatMinVersion)

we could just return the output from validatePluginImage (see, e.g., dsadeviceplugin_webhook.go)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the input. Done. Please take a look.

if len(parts) != 2 {
return errors.Errorf("incorrect image field %q", r.Spec.Image)
}
namespacedName := parts[0]
versionStr := parts[1]

parts = strings.Split(namespacedName, "/")
name := parts[len(parts)-1]
if name != "intel-qat-plugin" {
return errors.Errorf("incorrect image name %q. Make sure you use '<vendor>/intel-qat-plugin:<version>'", name)
}

ver, err := version.ParseSemantic(versionStr)
if err != nil {
return errors.Wrapf(err, "unable to parse version %q", versionStr)
}

if !ver.AtLeast(qatMinVersion) {
return errors.Errorf("version %q is too low. Should be at least %q", ver, qatMinVersion)
}

return nil
return validatePluginImage(r.Spec.Image, "intel-qat-plugin", qatMinVersion)
}