From e972c1e49c93ebfd1502c64abe379ff28fb01807 Mon Sep 17 00:00:00 2001 From: Mattia Lavacca Date: Thu, 14 Dec 2023 15:04:45 +0100 Subject: [PATCH] chore: address review's suggestions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Grzegorz BurzyƄski Signed-off-by: Mattia Lavacca --- CHANGELOG.md | 2 +- .../kongupstreampolicy_utils_test.go | 28 +++++++++---------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 64d9909d05..8ed6016659 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -125,7 +125,7 @@ Adding a new version? You'll need three changes: - using filters in backendRefs of rules [#5312](https://github.com/Kong/kubernetes-ingress-controller/pull/5312) - Added functionality to the `KongUpstreamPolicy` controller to properly set and - enforce `KongUpstreamPolicy`status. + enforce `KongUpstreamPolicy` status. [#5185](https://github.com/Kong/kubernetes-ingress-controller/pull/5185) ### Fixed diff --git a/internal/controllers/configuration/kongupstreampolicy_utils_test.go b/internal/controllers/configuration/kongupstreampolicy_utils_test.go index 2da3dc8e53..59e9bbd4e9 100644 --- a/internal/controllers/configuration/kongupstreampolicy_utils_test.go +++ b/internal/controllers/configuration/kongupstreampolicy_utils_test.go @@ -29,14 +29,14 @@ func TestEnforceKongUpstreamPolicyStatus(t *testing.T) { testCases := []struct { name string - kongupstreamPolicy kongv1beta1.KongUpstreamPolicy + kongUpstreamPolicy kongv1beta1.KongUpstreamPolicy inputObjects []client.Object - expectedkongUpstreamPolicyStatus gatewayapi.PolicyStatus + expectedKongUpstreamPolicyStatus gatewayapi.PolicyStatus updated bool }{ { name: "2 services referencing the same policy, all accepted. Status update.", - kongupstreamPolicy: kongv1beta1.KongUpstreamPolicy{ + kongUpstreamPolicy: kongv1beta1.KongUpstreamPolicy{ ObjectMeta: metav1.ObjectMeta{ Name: policyName, Namespace: testNamespace, @@ -94,7 +94,7 @@ func TestEnforceKongUpstreamPolicyStatus(t *testing.T) { }, }, }, - expectedkongUpstreamPolicyStatus: gatewayapi.PolicyStatus{ + expectedKongUpstreamPolicyStatus: gatewayapi.PolicyStatus{ Ancestors: []gatewayapi.PolicyAncestorStatus{ { AncestorRef: gatewayapi.ParentReference{ @@ -134,7 +134,7 @@ func TestEnforceKongUpstreamPolicyStatus(t *testing.T) { }, { name: "2 services referencing the same policy, all accepted. No status update.", - kongupstreamPolicy: kongv1beta1.KongUpstreamPolicy{ + kongUpstreamPolicy: kongv1beta1.KongUpstreamPolicy{ ObjectMeta: metav1.ObjectMeta{ Name: policyName, Namespace: testNamespace, @@ -228,7 +228,7 @@ func TestEnforceKongUpstreamPolicyStatus(t *testing.T) { }, }, }, - expectedkongUpstreamPolicyStatus: gatewayapi.PolicyStatus{ + expectedKongUpstreamPolicyStatus: gatewayapi.PolicyStatus{ Ancestors: []gatewayapi.PolicyAncestorStatus{ { AncestorRef: gatewayapi.ParentReference{ @@ -268,7 +268,7 @@ func TestEnforceKongUpstreamPolicyStatus(t *testing.T) { }, { name: "2 services referencing different policies, policy with conflict", - kongupstreamPolicy: kongv1beta1.KongUpstreamPolicy{ + kongUpstreamPolicy: kongv1beta1.KongUpstreamPolicy{ ObjectMeta: metav1.ObjectMeta{ Name: policyName, Namespace: testNamespace, @@ -326,7 +326,7 @@ func TestEnforceKongUpstreamPolicyStatus(t *testing.T) { }, }, }, - expectedkongUpstreamPolicyStatus: gatewayapi.PolicyStatus{ + expectedKongUpstreamPolicyStatus: gatewayapi.PolicyStatus{ Ancestors: []gatewayapi.PolicyAncestorStatus{ { AncestorRef: gatewayapi.ParentReference{ @@ -356,7 +356,7 @@ func TestEnforceKongUpstreamPolicyStatus(t *testing.T) { for _, tc := range testCases { tc := tc t.Run(tc.name, func(t *testing.T) { - objectsToAdd := append(tc.inputObjects, &tc.kongupstreamPolicy) + objectsToAdd := append(tc.inputObjects, &tc.kongUpstreamPolicy) fakeClient := fakectrlruntimeclient. NewClientBuilder(). WithScheme(scheme.Scheme). @@ -370,17 +370,17 @@ func TestEnforceKongUpstreamPolicyStatus(t *testing.T) { Client: fakeClient, } - updated, err := reconciler.enforceKongUpstreamPolicyStatus(context.TODO(), &tc.kongupstreamPolicy) + updated, err := reconciler.enforceKongUpstreamPolicyStatus(context.TODO(), &tc.kongUpstreamPolicy) assert.NoError(t, err) assert.Equal(t, tc.updated, updated) newPolicy := &kongv1beta1.KongUpstreamPolicy{} assert.NoError(t, fakeClient.Get(context.TODO(), k8stypes.NamespacedName{ - Namespace: tc.kongupstreamPolicy.Namespace, - Name: tc.kongupstreamPolicy.Name, + Namespace: tc.kongUpstreamPolicy.Namespace, + Name: tc.kongUpstreamPolicy.Name, }, newPolicy)) - assert.Len(t, newPolicy.Status.Ancestors, len(tc.expectedkongUpstreamPolicyStatus.Ancestors)) + assert.Len(t, newPolicy.Status.Ancestors, len(tc.expectedKongUpstreamPolicyStatus.Ancestors)) for i, got := range newPolicy.Status.Ancestors { - expected := tc.expectedkongUpstreamPolicyStatus.Ancestors[i] + expected := tc.expectedKongUpstreamPolicyStatus.Ancestors[i] assert.Equal(t, expected.ControllerName, got.ControllerName) assert.Equal(t, expected.AncestorRef, got.AncestorRef) assert.Len(t, got.Conditions, len(expected.Conditions))