Skip to content

Commit

Permalink
nil check for replica count for rollout and deployment client
Browse files Browse the repository at this point in the history
  • Loading branch information
deefreak committed Jan 12, 2024
1 parent 199c7f4 commit ac44ad9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion pkg/registry/deployment_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,10 @@ func (dc *DeploymentClient) GetReplicaCount(namespace string, name string) (int,
if err := dc.k8sClient.Get(context.Background(), types.NamespacedName{Namespace: namespace, Name: name}, deploymentObject); err != nil {
return 0, err
}
return int(*deploymentObject.Spec.Replicas), nil
if deploymentObject.Spec.Replicas != nil {
return int(*deploymentObject.Spec.Replicas), nil
}
return 0, fmt.Errorf("replica count not present")
}

func (dc *DeploymentClient) Scale(namespace string, name string, replicas int32) error {
Expand Down
5 changes: 4 additions & 1 deletion pkg/registry/rollout_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,10 @@ func (rc *RolloutClient) GetReplicaCount(namespace string, name string) (int, er
if err := rc.k8sClient.Get(context.Background(), types.NamespacedName{Namespace: namespace, Name: name}, rolloutObject); err != nil {
return 0, err
}
return int(*rolloutObject.Spec.Replicas), nil
if rolloutObject.Spec.Replicas != nil {
return int(*rolloutObject.Spec.Replicas), nil
}
return 0, fmt.Errorf("replica count not present")
}

func (rc *RolloutClient) Scale(namespace string, name string, replicas int32) error {
Expand Down

0 comments on commit ac44ad9

Please sign in to comment.