Skip to content

Commit

Permalink
Make Replicas a pointer
Browse files Browse the repository at this point in the history
  • Loading branch information
dharmit committed Jan 25, 2022
1 parent cce70f9 commit 145564e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
8 changes: 3 additions & 5 deletions pkg/devfile/generator/generators.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pkg/devfile/generator/generators_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1051,7 +1051,7 @@ func TestGetDeployment(t *testing.T) {
},
},
Containers: containers,
Replicas: 1,
Replicas: pointer.Int32Ptr(1),
},
expected: appsv1.Deployment{
ObjectMeta: objectMetaDedicatedPod,
Expand Down

0 comments on commit 145564e

Please sign in to comment.