Skip to content

Commit 25868eb

Browse files
authored
refactor: Use CAPI conditions check where possible (#789)
**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. -->
1 parent a603e7f commit 25868eb

File tree

1 file changed

+2
-7
lines changed
  • pkg/handlers/generic/lifecycle/serviceloadbalancer/metallb

1 file changed

+2
-7
lines changed

pkg/handlers/generic/lifecycle/serviceloadbalancer/metallb/handler.go

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ import (
1010

1111
"github.com/go-logr/logr"
1212
"github.com/spf13/pflag"
13-
corev1 "k8s.io/api/core/v1"
1413
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1514
kwait "k8s.io/apimachinery/pkg/util/wait"
1615
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
1716
"sigs.k8s.io/cluster-api/controllers/remote"
17+
"sigs.k8s.io/cluster-api/util/conditions"
1818
ctrlclient "sigs.k8s.io/controller-runtime/pkg/client"
1919
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
2020

@@ -164,12 +164,7 @@ func (n *MetalLB) Apply(
164164
Reader: n.client,
165165
Target: hcp.DeepCopy(),
166166
Check: func(_ context.Context, obj *caaphv1.HelmChartProxy) (bool, error) {
167-
for _, c := range obj.GetConditions() {
168-
if c.Type == caaphv1.HelmReleaseProxiesReadyCondition && c.Status == corev1.ConditionTrue {
169-
return true, nil
170-
}
171-
}
172-
return false, nil
167+
return conditions.IsTrue(obj, caaphv1.HelmReleaseProxiesReadyCondition), nil
173168
},
174169
Interval: 5 * time.Second,
175170
Timeout: 30 * time.Second,

0 commit comments

Comments
 (0)