Skip to content

Commit

Permalink
refactor: Use CAPI conditions check where possible (#789)
Browse files Browse the repository at this point in the history
**What problem does this PR solve?**:
Simplifies code to check a condition.

**Which issue(s) this PR fixes**:
Fixes #

**How Has This Been Tested?**:
<!--
Please describe the tests that you ran to verify your changes.
Provide output from the tests and any manual steps needed to replicate
the tests.
-->

**Special notes for your reviewer**:
<!--
Use this to provide any additional information to the reviewers.
This may include:
- Best way to review the PR.
- Where the author wants the most review attention on.
- etc.
-->
  • Loading branch information
dlipovetsky authored Jul 15, 2024
1 parent a603e7f commit 25868eb
Showing 1 changed file with 2 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import (

"github.com/go-logr/logr"
"github.com/spf13/pflag"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
kwait "k8s.io/apimachinery/pkg/util/wait"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
"sigs.k8s.io/cluster-api/controllers/remote"
"sigs.k8s.io/cluster-api/util/conditions"
ctrlclient "sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"

Expand Down Expand Up @@ -164,12 +164,7 @@ func (n *MetalLB) Apply(
Reader: n.client,
Target: hcp.DeepCopy(),
Check: func(_ context.Context, obj *caaphv1.HelmChartProxy) (bool, error) {
for _, c := range obj.GetConditions() {
if c.Type == caaphv1.HelmReleaseProxiesReadyCondition && c.Status == corev1.ConditionTrue {
return true, nil
}
}
return false, nil
return conditions.IsTrue(obj, caaphv1.HelmReleaseProxiesReadyCondition), nil
},
Interval: 5 * time.Second,
Timeout: 30 * time.Second,
Expand Down

0 comments on commit 25868eb

Please sign in to comment.