forked from openshift/apiserver-library-go
/
helpers.go
32 lines (28 loc) · 1.11 KB
/
helpers.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package imagepolicy
import (
imagepolicyapiv1 "github.com/openshift/apiserver-library-go/pkg/admission/imagepolicy/apis/imagepolicy/v1"
)
// RequestsResolution returns true if you should attempt to resolve image pull specs
func RequestsResolution(imageResolutionType imagepolicyapiv1.ImageResolutionType) bool {
switch imageResolutionType {
case imagepolicyapiv1.RequiredRewrite, imagepolicyapiv1.Required, imagepolicyapiv1.AttemptRewrite, imagepolicyapiv1.Attempt:
return true
}
return false
}
// FailOnResolutionFailure returns true if you should fail when resolution fails
func FailOnResolutionFailure(imageResolutionType imagepolicyapiv1.ImageResolutionType) bool {
switch imageResolutionType {
case imagepolicyapiv1.RequiredRewrite, imagepolicyapiv1.Required:
return true
}
return false
}
// RewriteImagePullSpec returns true if you should rewrite image pull specs when resolution succeeds
func RewriteImagePullSpec(imageResolutionType imagepolicyapiv1.ImageResolutionType) bool {
switch imageResolutionType {
case imagepolicyapiv1.RequiredRewrite, imagepolicyapiv1.AttemptRewrite:
return true
}
return false
}