Skip to content

Commit

Permalink
move helper to single point of use
Browse files Browse the repository at this point in the history
  • Loading branch information
deads2k committed Nov 28, 2017
1 parent 4023e66 commit e825c5f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
11 changes: 0 additions & 11 deletions pkg/apps/apis/apps/v1/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,6 @@ import (
deployapi "github.com/openshift/origin/pkg/apps/apis/apps"
)

// Applies defaults only for API group "apps.openshift.io" and not for the legacy API.
// This function is called from storage layer where differentiation
// between legacy and group API can be made and is not related to other functions here
// which are called fom auto-generated code.
func AppsV1DeploymentConfigLayeredDefaults(dc *deployapi.DeploymentConfig) {
if dc.Spec.RevisionHistoryLimit == nil {
v := deployapi.DefaultRevisionHistoryLimit
dc.Spec.RevisionHistoryLimit = &v
}
}

// Keep this in sync with pkg/api/serialization_test.go#defaultHookContainerName
func defaultHookContainerName(hook *v1.LifecycleHook, containerName string) {
if hook == nil {
Expand Down
14 changes: 12 additions & 2 deletions pkg/apps/registry/deployconfig/strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"k8s.io/apiserver/pkg/storage/names"
kapi "k8s.io/kubernetes/pkg/api"

deployapiv1 "github.com/openshift/api/apps/v1"
deployapi "github.com/openshift/origin/pkg/apps/apis/apps"
"github.com/openshift/origin/pkg/apps/apis/apps/validation"
)
Expand Down Expand Up @@ -136,7 +135,7 @@ func (s groupStrategy) PrepareForCreate(ctx apirequest.Context, obj runtime.Obje
s.strategy.PrepareForCreate(ctx, obj)

dc := obj.(*deployapi.DeploymentConfig)
deployapiv1.AppsV1DeploymentConfigLayeredDefaults(dc)
appsV1DeploymentConfigLayeredDefaults(dc)
}

// statusStrategy implements behavior for DeploymentConfig status updates.
Expand All @@ -158,3 +157,14 @@ func (statusStrategy) PrepareForUpdate(ctx apirequest.Context, obj, old runtime.
func (statusStrategy) ValidateUpdate(ctx apirequest.Context, obj, old runtime.Object) field.ErrorList {
return validation.ValidateDeploymentConfigStatusUpdate(obj.(*deployapi.DeploymentConfig), old.(*deployapi.DeploymentConfig))
}

// Applies defaults only for API group "apps.openshift.io" and not for the legacy API.
// This function is called from storage layer where differentiation
// between legacy and group API can be made and is not related to other functions here
// which are called fom auto-generated code.
func appsV1DeploymentConfigLayeredDefaults(dc *deployapi.DeploymentConfig) {
if dc.Spec.RevisionHistoryLimit == nil {
v := deployapi.DefaultRevisionHistoryLimit
dc.Spec.RevisionHistoryLimit = &v
}
}

0 comments on commit e825c5f

Please sign in to comment.