Skip to content

Commit e825c5f

Browse files
committed
move helper to single point of use
1 parent 4023e66 commit e825c5f

File tree

2 files changed

+12
-13
lines changed

2 files changed

+12
-13
lines changed

pkg/apps/apis/apps/v1/defaults.go

-11
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,6 @@ import (
77
deployapi "github.com/openshift/origin/pkg/apps/apis/apps"
88
)
99

10-
// Applies defaults only for API group "apps.openshift.io" and not for the legacy API.
11-
// This function is called from storage layer where differentiation
12-
// between legacy and group API can be made and is not related to other functions here
13-
// which are called fom auto-generated code.
14-
func AppsV1DeploymentConfigLayeredDefaults(dc *deployapi.DeploymentConfig) {
15-
if dc.Spec.RevisionHistoryLimit == nil {
16-
v := deployapi.DefaultRevisionHistoryLimit
17-
dc.Spec.RevisionHistoryLimit = &v
18-
}
19-
}
20-
2110
// Keep this in sync with pkg/api/serialization_test.go#defaultHookContainerName
2211
func defaultHookContainerName(hook *v1.LifecycleHook, containerName string) {
2312
if hook == nil {

pkg/apps/registry/deployconfig/strategy.go

+12-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111
"k8s.io/apiserver/pkg/storage/names"
1212
kapi "k8s.io/kubernetes/pkg/api"
1313

14-
deployapiv1 "github.com/openshift/api/apps/v1"
1514
deployapi "github.com/openshift/origin/pkg/apps/apis/apps"
1615
"github.com/openshift/origin/pkg/apps/apis/apps/validation"
1716
)
@@ -136,7 +135,7 @@ func (s groupStrategy) PrepareForCreate(ctx apirequest.Context, obj runtime.Obje
136135
s.strategy.PrepareForCreate(ctx, obj)
137136

138137
dc := obj.(*deployapi.DeploymentConfig)
139-
deployapiv1.AppsV1DeploymentConfigLayeredDefaults(dc)
138+
appsV1DeploymentConfigLayeredDefaults(dc)
140139
}
141140

142141
// statusStrategy implements behavior for DeploymentConfig status updates.
@@ -158,3 +157,14 @@ func (statusStrategy) PrepareForUpdate(ctx apirequest.Context, obj, old runtime.
158157
func (statusStrategy) ValidateUpdate(ctx apirequest.Context, obj, old runtime.Object) field.ErrorList {
159158
return validation.ValidateDeploymentConfigStatusUpdate(obj.(*deployapi.DeploymentConfig), old.(*deployapi.DeploymentConfig))
160159
}
160+
161+
// Applies defaults only for API group "apps.openshift.io" and not for the legacy API.
162+
// This function is called from storage layer where differentiation
163+
// between legacy and group API can be made and is not related to other functions here
164+
// which are called fom auto-generated code.
165+
func appsV1DeploymentConfigLayeredDefaults(dc *deployapi.DeploymentConfig) {
166+
if dc.Spec.RevisionHistoryLimit == nil {
167+
v := deployapi.DefaultRevisionHistoryLimit
168+
dc.Spec.RevisionHistoryLimit = &v
169+
}
170+
}

0 commit comments

Comments
 (0)