From 145564efc02c37f573608a4875e81009f3da3427 Mon Sep 17 00:00:00 2001 From: Dharmit Shah Date: Tue, 25 Jan 2022 13:03:38 +0530 Subject: [PATCH] Make Replicas a pointer --- pkg/devfile/generator/generators.go | 8 +++----- pkg/devfile/generator/generators_test.go | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/pkg/devfile/generator/generators.go b/pkg/devfile/generator/generators.go index 3582326f..7f917f87 100644 --- a/pkg/devfile/generator/generators.go +++ b/pkg/devfile/generator/generators.go @@ -2,8 +2,6 @@ package generator import ( "fmt" - "k8s.io/utils/pointer" - v1 "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2" "github.com/devfile/library/pkg/devfile/parser" "github.com/devfile/library/pkg/devfile/parser/data/v2/common" @@ -159,7 +157,7 @@ type DeploymentParams struct { Containers []corev1.Container Volumes []corev1.Volume PodSelectorLabels map[string]string - Replicas int32 + Replicas *int32 } // GetDeployment gets a deployment object @@ -189,8 +187,8 @@ func GetDeployment(devfileObj parser.DevfileObj, deployParams DeploymentParams) Spec: *getDeploymentSpec(deploySpecParams), } - if deployParams.Replicas != 0 { - deployment.Spec.Replicas = pointer.Int32Ptr(deployParams.Replicas) + if deployParams.Replicas != nil { + deployment.Spec.Replicas = deployParams.Replicas } return deployment, nil diff --git a/pkg/devfile/generator/generators_test.go b/pkg/devfile/generator/generators_test.go index 49cb00ee..49b1b31a 100644 --- a/pkg/devfile/generator/generators_test.go +++ b/pkg/devfile/generator/generators_test.go @@ -1051,7 +1051,7 @@ func TestGetDeployment(t *testing.T) { }, }, Containers: containers, - Replicas: 1, + Replicas: pointer.Int32Ptr(1), }, expected: appsv1.Deployment{ ObjectMeta: objectMetaDedicatedPod,