Skip to content

Commit 8c44d55

Browse files
committed
Rebase and fixes
1 parent 9d90b7b commit 8c44d55

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

controllers/helpers.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1083,12 +1083,12 @@ func RemoveBlockMoveAnnotation(obj metav1.Object) {
10831083
// getAzureClusterFromCluster returns the AzureCluster for a Cluster if the infraRef is an AzureCluster.
10841084
// Returns nil if the infraRef is not an AzureCluster or if the AzureCluster cannot be fetched.
10851085
func getAzureClusterFromCluster(ctx context.Context, c client.Client, cluster *clusterv1.Cluster) *infrav1.AzureCluster {
1086-
if cluster.Spec.InfrastructureRef == nil || cluster.Spec.InfrastructureRef.Kind != infrav1.AzureClusterKind {
1086+
if !cluster.Spec.InfrastructureRef.IsDefined() || cluster.Spec.InfrastructureRef.Kind != infrav1.AzureClusterKind {
10871087
return nil
10881088
}
10891089
azureCluster := &infrav1.AzureCluster{}
10901090
key := client.ObjectKey{
1091-
Namespace: cluster.Spec.InfrastructureRef.Namespace,
1091+
Namespace: cluster.Namespace,
10921092
Name: cluster.Spec.InfrastructureRef.Name,
10931093
}
10941094
if err := c.Get(ctx, key, azureCluster); err != nil {

controllers/helpers_test.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1607,10 +1607,10 @@ func TestGetAzureClusterFromCluster(t *testing.T) {
16071607
cluster: &clusterv1.Cluster{
16081608
ObjectMeta: metav1.ObjectMeta{Name: "cluster", Namespace: "default"},
16091609
Spec: clusterv1.ClusterSpec{
1610-
InfrastructureRef: &corev1.ObjectReference{
1611-
Kind: infrav1.AzureClusterKind,
1612-
Name: "azure-cluster",
1613-
Namespace: "default",
1610+
InfrastructureRef: clusterv1.ContractVersionedObjectReference{
1611+
Kind: infrav1.AzureClusterKind,
1612+
Name: "azure-cluster",
1613+
APIGroup: infrav1.GroupVersion.Group,
16141614
},
16151615
},
16161616
},
@@ -1633,10 +1633,10 @@ func TestGetAzureClusterFromCluster(t *testing.T) {
16331633
cluster: &clusterv1.Cluster{
16341634
ObjectMeta: metav1.ObjectMeta{Name: "cluster", Namespace: "default"},
16351635
Spec: clusterv1.ClusterSpec{
1636-
InfrastructureRef: &corev1.ObjectReference{
1637-
Kind: infrav1.AzureManagedClusterKind,
1638-
Name: "azure-managed-cluster",
1639-
Namespace: "default",
1636+
InfrastructureRef: clusterv1.ContractVersionedObjectReference{
1637+
Kind: infrav1.AzureManagedClusterKind,
1638+
Name: "azure-managed-cluster",
1639+
APIGroup: infrav1.GroupVersion.Group,
16401640
},
16411641
},
16421642
},
@@ -1648,10 +1648,10 @@ func TestGetAzureClusterFromCluster(t *testing.T) {
16481648
cluster: &clusterv1.Cluster{
16491649
ObjectMeta: metav1.ObjectMeta{Name: "cluster", Namespace: "default"},
16501650
Spec: clusterv1.ClusterSpec{
1651-
InfrastructureRef: &corev1.ObjectReference{
1652-
Kind: infrav1.AzureClusterKind,
1653-
Name: "missing-cluster",
1654-
Namespace: "default",
1651+
InfrastructureRef: clusterv1.ContractVersionedObjectReference{
1652+
Kind: infrav1.AzureClusterKind,
1653+
Name: "missing-cluster",
1654+
APIGroup: infrav1.GroupVersion.Group,
16551655
},
16561656
},
16571657
},

0 commit comments

Comments
 (0)