Skip to content

Commit b6e3eb8

Browse files
committed
operator: accept image SHA digests
Signed-off-by: Mikko Ylinen <[email protected]>
1 parent e56e0e6 commit b6e3eb8

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

pkg/apis/deviceplugin/v1/webhook_common.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,23 @@ package v1
1616

1717
import (
1818
"path/filepath"
19+
"regexp"
1920
"strings"
2021

2122
"github.com/pkg/errors"
2223
"k8s.io/apimachinery/pkg/util/version"
2324
)
2425

26+
const sha256RE = "@sha256:[0-9a-f]{64}$"
27+
2528
// common functions for webhooks
2629

2730
func validatePluginImage(image, expectedImageName string, expectedMinVersion *version.Version) error {
31+
imageRe := regexp.MustCompile(expectedImageName + sha256RE)
32+
if imageRe.MatchString(image) {
33+
return nil
34+
}
35+
2836
// Ignore registry, vendor and extract the image name with the tag
2937
parts := strings.SplitN(filepath.Base(image), ":", 2)
3038
if len(parts) != 2 {
@@ -35,7 +43,7 @@ func validatePluginImage(image, expectedImageName string, expectedMinVersion *ve
3543
versionStr := parts[1]
3644

3745
if imageName != expectedImageName {
38-
return errors.Errorf("incorrect image name %q. Make sure you use '<vendor>/%s:<version>'", imageName, expectedImageName)
46+
return errors.Errorf("incorrect image name %q. Make sure you use '<vendor>/%s.", strings.TrimSuffix(imageName, "@sha256"), expectedImageName)
3947
}
4048

4149
ver, err := version.ParseSemantic(versionStr)

0 commit comments

Comments
 (0)