Skip to content

Commit 145564e

Browse files
committed
Make Replicas a pointer
1 parent cce70f9 commit 145564e

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

pkg/devfile/generator/generators.go

+3-5
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ package generator
22

33
import (
44
"fmt"
5-
"k8s.io/utils/pointer"
6-
75
v1 "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2"
86
"github.com/devfile/library/pkg/devfile/parser"
97
"github.com/devfile/library/pkg/devfile/parser/data/v2/common"
@@ -159,7 +157,7 @@ type DeploymentParams struct {
159157
Containers []corev1.Container
160158
Volumes []corev1.Volume
161159
PodSelectorLabels map[string]string
162-
Replicas int32
160+
Replicas *int32
163161
}
164162

165163
// GetDeployment gets a deployment object
@@ -189,8 +187,8 @@ func GetDeployment(devfileObj parser.DevfileObj, deployParams DeploymentParams)
189187
Spec: *getDeploymentSpec(deploySpecParams),
190188
}
191189

192-
if deployParams.Replicas != 0 {
193-
deployment.Spec.Replicas = pointer.Int32Ptr(deployParams.Replicas)
190+
if deployParams.Replicas != nil {
191+
deployment.Spec.Replicas = deployParams.Replicas
194192
}
195193

196194
return deployment, nil

pkg/devfile/generator/generators_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1051,7 +1051,7 @@ func TestGetDeployment(t *testing.T) {
10511051
},
10521052
},
10531053
Containers: containers,
1054-
Replicas: 1,
1054+
Replicas: pointer.Int32Ptr(1),
10551055
},
10561056
expected: appsv1.Deployment{
10571057
ObjectMeta: objectMetaDedicatedPod,

0 commit comments

Comments
 (0)