Skip to content

Commit

Permalink
Merge pull request #102 from deefreak/ossbug
Browse files Browse the repository at this point in the history
Nil check for replica count for rollout and deployment client
  • Loading branch information
bharathguvvala authored Jan 12, 2024
2 parents f7934b1 + ebd7934 commit 7beece4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/registry/deployment_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ 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
}
if deploymentObject.Spec.Replicas == nil {
return 0, fmt.Errorf("replica count not present")
}
return int(*deploymentObject.Spec.Replicas), nil
}

Expand Down
3 changes: 3 additions & 0 deletions pkg/registry/rollout_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ 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
}
if rolloutObject.Spec.Replicas == nil {
return 0, fmt.Errorf("replica count not present")
}
return int(*rolloutObject.Spec.Replicas), nil
}

Expand Down

0 comments on commit 7beece4

Please sign in to comment.