-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update image policy API for first class resolution
- Loading branch information
Showing
16 changed files
with
244 additions
and
195 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package api | ||
|
||
// RequestsResolution returns true if you should attempt to resolve image pull specs | ||
func RequestsResolution(imageResolutionType ImageResolutionType) bool { | ||
switch imageResolutionType { | ||
case RequiredRewrite, Required, AttemptRewrite, Attempt: | ||
return true | ||
} | ||
return false | ||
} | ||
|
||
// FailOnResolutionFailure returns true if you should fail when resolution fails | ||
func FailOnResolutionFailure(imageResolutionType ImageResolutionType) bool { | ||
switch imageResolutionType { | ||
case RequiredRewrite, Required: | ||
return true | ||
} | ||
return false | ||
} | ||
|
||
// RewriteImagePullSpec returns true if you should rewrite image pull specs when resolution succeeds | ||
func RewriteImagePullSpec(imageResolutionType ImageResolutionType) bool { | ||
switch imageResolutionType { | ||
case RequiredRewrite, AttemptRewrite: | ||
return true | ||
} | ||
return false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package v1 | ||
|
||
import ( | ||
kapi "k8s.io/kubernetes/pkg/api" | ||
"k8s.io/kubernetes/pkg/runtime" | ||
) | ||
|
||
func SetDefaults_ImagePolicyConfig(obj *ImagePolicyConfig) { | ||
if obj == nil { | ||
return | ||
} | ||
|
||
if len(obj.ResolveImages) == 0 { | ||
obj.ResolveImages = Attempt | ||
} | ||
|
||
for i := range obj.ExecutionRules { | ||
if len(obj.ExecutionRules[i].OnResources) == 0 { | ||
obj.ExecutionRules[i].OnResources = []GroupResource{{Resource: "pods", Group: kapi.GroupName}} | ||
} | ||
} | ||
|
||
} | ||
|
||
func addDefaultingFuncs(scheme *runtime.Scheme) { | ||
err := scheme.AddDefaultingFuncs( | ||
SetDefaults_ImagePolicyConfig, | ||
) | ||
if err != nil { | ||
panic(err) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.