Skip to content

Commit 474e961

Browse files
committed
fixup! chore: inline v1beta1 helper utils to enable upgrade
1 parent c0eb5d3 commit 474e961

File tree

2 files changed

+5
-11
lines changed

2 files changed

+5
-11
lines changed

pkg/capiutils/predicates.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17+
// Package capiutils contains utility functions for working with Cluster API resources.
18+
// These have mostly been inlined as part of the CAPI 1.10 -> 1.11 upgrade,
19+
// and should be removed when we switch to reading CAPI v1beta2 objects.
20+
//
21+
// Deprecated: This package is deprecated and is going to be removed when support for v1beta1 will be dropped.
1722
package capiutils
1823

1924
import (
@@ -33,7 +38,6 @@ import (
3338

3439
// ClusterUpdateInfraReady returns a predicate that returns true for an update event when a cluster has Status.InfrastructureReady changed from false to true
3540
// it also returns true if the resource provided is not a Cluster to allow for use with controller-runtime NewControllerManagedBy.
36-
// Deprecated: replace with predicates.ClusterUpdateInfraReady when we move to v1beta2
3741
func ClusterUpdateInfraReady(scheme *runtime.Scheme, logger logr.Logger) predicate.Funcs {
3842
return predicate.Funcs{
3943
UpdateFunc: func(e event.UpdateEvent) bool {
@@ -65,7 +69,6 @@ func ClusterUpdateInfraReady(scheme *runtime.Scheme, logger logr.Logger) predica
6569
}
6670

6771
// ClusterPausedTransitions returns a predicate that returns true for an update event when a cluster has Spec.Paused changed.
68-
// Deprecated: replace with predicates.ClusterPausedTransitions when we move to v1beta2
6972
func ClusterPausedTransitions(scheme *runtime.Scheme, logger logr.Logger) predicate.Funcs {
7073
return predicate.Funcs{
7174
UpdateFunc: func(e event.UpdateEvent) bool {
@@ -114,8 +117,6 @@ func ClusterPausedTransitions(scheme *runtime.Scheme, logger logr.Logger) predic
114117
// handler.EnqueueRequestsFromMapFunc(clusterToMachines)
115118
// predicates.ClusterPausedTransitionsOrInfrastructureReady(mgr.GetScheme(), r.Log),
116119
// )
117-
//
118-
// Deprecated: replace with predicates.ClusterPausedTransitionsOrInfrastructureReady when we move to v1beta2
119120
func ClusterPausedTransitionsOrInfrastructureReady(scheme *runtime.Scheme, logger logr.Logger) predicate.Funcs {
120121
log := logger.WithValues("predicate", "ClusterPausedTransitionsOrInfrastructureReady")
121122

pkg/capiutils/utils.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,12 @@ import (
3030
)
3131

3232
// IsControlPlaneMachine checks machine is a control plane node.
33-
// Deprecated: Replace with util.IsControlPlaneMachine when we move to capi v1.11
3433
func IsControlPlaneMachine(machine *capiv1beta1.Machine) bool {
3534
_, ok := machine.Labels[capiv1beta1.MachineControlPlaneLabel]
3635
return ok
3736
}
3837

3938
// GetOwnerCluster returns the Cluster object owning the current resource.
40-
// Deprecated: Replace with util.IsControlPlaneMachine when we move to capi v1.11
4139
func GetOwnerCluster(ctx context.Context, c client.Client, obj metav1.ObjectMeta) (*capiv1beta1.Cluster, error) {
4240
for _, ref := range obj.GetOwnerReferences() {
4341
if ref.Kind != "Cluster" {
@@ -55,7 +53,6 @@ func GetOwnerCluster(ctx context.Context, c client.Client, obj metav1.ObjectMeta
5553
}
5654

5755
// GetClusterFromMetadata returns the Cluster object (if present) using the object metadata.
58-
// Deprecated: Replace with util.GetClusterFromMetadata when we move to capi v1.11
5956
func GetClusterFromMetadata(ctx context.Context, c client.Client, obj metav1.ObjectMeta) (*capiv1beta1.Cluster, error) {
6057
if obj.Labels[capiv1beta1.ClusterNameLabel] == "" {
6158
return nil, errors.WithStack(util.ErrNoCluster)
@@ -64,7 +61,6 @@ func GetClusterFromMetadata(ctx context.Context, c client.Client, obj metav1.Obj
6461
}
6562

6663
// GetClusterByName finds and return a Cluster object using the specified params.
67-
// Deprecated: Replace with util.GetClusterByName when we move to capi v1.11
6864
func GetClusterByName(ctx context.Context, c client.Client, namespace, name string) (*capiv1beta1.Cluster, error) {
6965
cluster := &capiv1beta1.Cluster{}
7066
key := client.ObjectKey{
@@ -80,7 +76,6 @@ func GetClusterByName(ctx context.Context, c client.Client, namespace, name stri
8076
}
8177

8278
// IsPaused returns true if the Cluster is paused or the object has the `paused` annotation.
83-
// Deprecated: Replace with annotations.IsPaused when we move to capi v1.11
8479
func IsPaused(cluster *capiv1beta1.Cluster, o metav1.Object) bool {
8580
if cluster.Spec.Paused {
8681
return true
@@ -89,7 +84,6 @@ func IsPaused(cluster *capiv1beta1.Cluster, o metav1.Object) bool {
8984
}
9085

9186
// GetOwnerMachine returns the Machine object owning the current resource.
92-
// Deprecated: Replace with util.GetOwnerMachine when we move to capi v1.11
9387
func GetOwnerMachine(ctx context.Context, c client.Client, obj metav1.ObjectMeta) (*capiv1beta1.Machine, error) {
9488
for _, ref := range obj.GetOwnerReferences() {
9589
gv, err := schema.ParseGroupVersion(ref.APIVersion)
@@ -104,7 +98,6 @@ func GetOwnerMachine(ctx context.Context, c client.Client, obj metav1.ObjectMeta
10498
}
10599

106100
// GetMachineByName finds and return a Machine object using the specified params.
107-
// Deprecated: Replace with util.GetMachineByName when we move to capi v1.11
108101
func GetMachineByName(ctx context.Context, c client.Client, namespace, name string) (*capiv1beta1.Machine, error) {
109102
m := &capiv1beta1.Machine{}
110103
key := client.ObjectKey{Name: name, Namespace: namespace}

0 commit comments

Comments
 (0)