Skip to content

Commit fa2a217

Browse files
authored
Merge pull request #648 from ozhuraki/qatdeviceplugin-webhook
qatdeviceplugin_webhook: Extract only relevant parts for the validation
2 parents 98f80b5 + 748863a commit fa2a217

File tree

1 file changed

+1
-25
lines changed

1 file changed

+1
-25
lines changed

pkg/apis/deviceplugin/v1/qatdeviceplugin_webhook.go

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
package v1
1616

1717
import (
18-
"strings"
19-
2018
"github.com/pkg/errors"
2119
"k8s.io/apimachinery/pkg/runtime"
2220
"k8s.io/apimachinery/pkg/util/version"
@@ -88,27 +86,5 @@ func (r *QatDevicePlugin) ValidateDelete() error {
8886
}
8987

9088
func (r *QatDevicePlugin) validatePlugin() error {
91-
parts := strings.SplitN(r.Spec.Image, ":", 2)
92-
if len(parts) != 2 {
93-
return errors.Errorf("incorrect image field %q", r.Spec.Image)
94-
}
95-
namespacedName := parts[0]
96-
versionStr := parts[1]
97-
98-
parts = strings.Split(namespacedName, "/")
99-
name := parts[len(parts)-1]
100-
if name != "intel-qat-plugin" {
101-
return errors.Errorf("incorrect image name %q. Make sure you use '<vendor>/intel-qat-plugin:<version>'", name)
102-
}
103-
104-
ver, err := version.ParseSemantic(versionStr)
105-
if err != nil {
106-
return errors.Wrapf(err, "unable to parse version %q", versionStr)
107-
}
108-
109-
if !ver.AtLeast(qatMinVersion) {
110-
return errors.Errorf("version %q is too low. Should be at least %q", ver, qatMinVersion)
111-
}
112-
113-
return nil
89+
return validatePluginImage(r.Spec.Image, "intel-qat-plugin", qatMinVersion)
11490
}

0 commit comments

Comments
 (0)