Move old defaulters to public functions

Also make Deployment defaulting resilient to fuzzing
This commit is contained in:
Clayton Coleman 2016-09-24 23:26:32 -04:00
parent 68a9983ec7
commit 0aa8da19a9
No known key found for this signature in database
GPG Key ID: 3D16906B4F1C5CB3
2 changed files with 14 additions and 11 deletions

View File

@ -71,7 +71,7 @@ func SetDefaults_Deployment(obj *Deployment) {
if strategy.Type == "" {
strategy.Type = RollingUpdateDeploymentStrategyType
}
if strategy.Type == RollingUpdateDeploymentStrategyType {
if strategy.Type == RollingUpdateDeploymentStrategyType || strategy.RollingUpdate != nil {
if strategy.RollingUpdate == nil {
rollingUpdate := RollingUpdateDeployment{}
strategy.RollingUpdate = &rollingUpdate

View File

@ -22,15 +22,18 @@ import (
func addDefaultingFuncs(scheme *runtime.Scheme) error {
return scheme.AddDefaultingFuncs(
func(obj *ClusterRoleBinding) {
if len(obj.RoleRef.APIGroup) == 0 {
obj.RoleRef.APIGroup = GroupName
}
},
func(obj *RoleBinding) {
if len(obj.RoleRef.APIGroup) == 0 {
obj.RoleRef.APIGroup = GroupName
}
},
SetDefaults_ClusterRoleBinding,
SetDefaults_RoleBinding,
)
}
func SetDefaults_ClusterRoleBinding(obj *ClusterRoleBinding) {
if len(obj.RoleRef.APIGroup) == 0 {
obj.RoleRef.APIGroup = GroupName
}
}
func SetDefaults_RoleBinding(obj *RoleBinding) {
if len(obj.RoleRef.APIGroup) == 0 {
obj.RoleRef.APIGroup = GroupName
}
}