From bf18f9f748948bc1d0f9461d1093b04e59a4ef22 Mon Sep 17 00:00:00 2001 From: anandf Date: Wed, 25 Sep 2024 00:02:25 +0530 Subject: [PATCH] Using require package instead of assert and fixed code generation Signed-off-by: anandf --- assets/swagger.json | 2 +- controller/sync_test.go | 28 +++++++++---------- manifests/core-install.yaml | 5 +++- manifests/crds/appproject-crd.yaml | 5 +++- manifests/ha/install.yaml | 5 +++- manifests/install.yaml | 5 +++- pkg/apis/application/v1alpha1/generated.proto | 2 +- 7 files changed, 32 insertions(+), 20 deletions(-) diff --git a/assets/swagger.json b/assets/swagger.json index 1e8a981c51c66..68027dc60a45a 100644 --- a/assets/swagger.json +++ b/assets/swagger.json @@ -6084,7 +6084,7 @@ "properties": { "defaultServiceAccount": { "type": "string", - "title": "ServiceAccountName to be used for impersonation during the sync operation" + "title": "DefaultServiceAccount to be used for impersonation during the sync operation" }, "namespace": { "description": "Namespace specifies the target namespace for the application's resources.", diff --git a/controller/sync_test.go b/controller/sync_test.go index 62536bf0aca01..acb298eb22209 100644 --- a/controller/sync_test.go +++ b/controller/sync_test.go @@ -720,7 +720,7 @@ func TestDeriveServiceAccountMatchingNamespaces(t *testing.T) { sa, err := deriveServiceAccountToImpersonate(f.project, f.application) // then, there should be no error and should use the right service account for impersonation - assert.NoError(t, err) + require.NoError(t, err) assert.Equal(t, expectedSA, sa) }) @@ -759,7 +759,7 @@ func TestDeriveServiceAccountMatchingNamespaces(t *testing.T) { sa, err := deriveServiceAccountToImpersonate(f.project, f.application) // then, there should be no error and should use the right service account for impersonation - assert.NoError(t, err) + require.NoError(t, err) assert.Equal(t, expectedSA, sa) }) @@ -798,7 +798,7 @@ func TestDeriveServiceAccountMatchingNamespaces(t *testing.T) { sa, err := deriveServiceAccountToImpersonate(f.project, f.application) // then, there should be no error and it should use the first matching service account for impersonation - assert.NoError(t, err) + require.NoError(t, err) assert.Equal(t, expectedSA, sa) }) @@ -832,7 +832,7 @@ func TestDeriveServiceAccountMatchingNamespaces(t *testing.T) { sa, err := deriveServiceAccountToImpersonate(f.project, f.application) // then, there should not be any error and should use the first matching glob pattern service account for impersonation - assert.NoError(t, err) + require.NoError(t, err) assert.Equal(t, expectedSA, sa) }) @@ -867,7 +867,7 @@ func TestDeriveServiceAccountMatchingNamespaces(t *testing.T) { sa, err := deriveServiceAccountToImpersonate(f.project, f.application) // then, there should be an error saying no match was found - assert.EqualError(t, err, expectedErrMsg) + require.EqualError(t, err, expectedErrMsg) assert.Equal(t, expectedSA, sa) }) @@ -895,7 +895,7 @@ func TestDeriveServiceAccountMatchingNamespaces(t *testing.T) { sa, err := deriveServiceAccountToImpersonate(f.project, f.application) // then, there should not be any error and the service account configured for with empty namespace should be used. - assert.NoError(t, err) + require.NoError(t, err) assert.Equal(t, expectedSA, sa) }) @@ -929,7 +929,7 @@ func TestDeriveServiceAccountMatchingNamespaces(t *testing.T) { sa, err := deriveServiceAccountToImpersonate(f.project, f.application) // then, there should not be any error and the catch all service account should be returned - assert.NoError(t, err) + require.NoError(t, err) assert.Equal(t, expectedSA, sa) }) @@ -964,7 +964,7 @@ func TestDeriveServiceAccountMatchingNamespaces(t *testing.T) { assert.Equal(t, expectedSA, sa) // then, there should not be any error and the service account with its namespace should be returned. - assert.NoError(t, err) + require.NoError(t, err) }) } @@ -1038,7 +1038,7 @@ func TestDeriveServiceAccountMatchingServers(t *testing.T) { sa, err := deriveServiceAccountToImpersonate(f.project, f.application) // then, there should not be any error and the right service account must be returned. - assert.NoError(t, err) + require.NoError(t, err) assert.Equal(t, expectedSA, sa) }) @@ -1077,7 +1077,7 @@ func TestDeriveServiceAccountMatchingServers(t *testing.T) { sa, err := deriveServiceAccountToImpersonate(f.project, f.application) // then, there should not be any error and first matching service account should be used - assert.NoError(t, err) + require.NoError(t, err) assert.Equal(t, expectedSA, sa) }) @@ -1112,7 +1112,7 @@ func TestDeriveServiceAccountMatchingServers(t *testing.T) { assert.Equal(t, expectedSA, sa) // then, there should not be any error and the service account of the glob pattern, being the first match should be returned. - assert.NoError(t, err) + require.NoError(t, err) }) t.Run("no match among a valid list", func(t *testing.T) { @@ -1146,7 +1146,7 @@ func TestDeriveServiceAccountMatchingServers(t *testing.T) { sa, err := deriveServiceAccountToImpersonate(f.project, f.application) // then, there an error with appropriate message must be returned - assert.EqualError(t, err, expectedErr) + require.EqualError(t, err, expectedErr) assert.Equal(t, expectedSA, sa) }) @@ -1180,7 +1180,7 @@ func TestDeriveServiceAccountMatchingServers(t *testing.T) { sa, err := deriveServiceAccountToImpersonate(f.project, f.application) // then, there should not be any error and the service account of the glob pattern match must be returned. - assert.NoError(t, err) + require.NoError(t, err) assert.Equal(t, expectedSA, sa) }) @@ -1214,7 +1214,7 @@ func TestDeriveServiceAccountMatchingServers(t *testing.T) { sa, err := deriveServiceAccountToImpersonate(f.project, f.application) // then, there should not be any error and the service account with the given namespace prefix must be returned. - assert.NoError(t, err) + require.NoError(t, err) assert.Equal(t, expectedSA, sa) }) } diff --git a/manifests/core-install.yaml b/manifests/core-install.yaml index b9d59aae424d0..e410cbbbfad77 100644 --- a/manifests/core-install.yaml +++ b/manifests/core-install.yaml @@ -21735,7 +21735,7 @@ spec: sync operation. properties: defaultServiceAccount: - description: ServiceAccountName to be used for impersonation + description: DefaultServiceAccount to be used for impersonation during the sync operation type: string namespace: @@ -21746,6 +21746,9 @@ spec: description: Server specifies the URL of the target cluster's Kubernetes control plane API. type: string + required: + - defaultServiceAccount + - server type: object type: array destinations: diff --git a/manifests/crds/appproject-crd.yaml b/manifests/crds/appproject-crd.yaml index 07e98e13b5928..a72a8de146939 100644 --- a/manifests/crds/appproject-crd.yaml +++ b/manifests/crds/appproject-crd.yaml @@ -95,7 +95,7 @@ spec: sync operation. properties: defaultServiceAccount: - description: ServiceAccountName to be used for impersonation + description: DefaultServiceAccount to be used for impersonation during the sync operation type: string namespace: @@ -106,6 +106,9 @@ spec: description: Server specifies the URL of the target cluster's Kubernetes control plane API. type: string + required: + - defaultServiceAccount + - server type: object type: array destinations: diff --git a/manifests/ha/install.yaml b/manifests/ha/install.yaml index 334b2befea9f1..2284eef1c3512 100644 --- a/manifests/ha/install.yaml +++ b/manifests/ha/install.yaml @@ -21735,7 +21735,7 @@ spec: sync operation. properties: defaultServiceAccount: - description: ServiceAccountName to be used for impersonation + description: DefaultServiceAccount to be used for impersonation during the sync operation type: string namespace: @@ -21746,6 +21746,9 @@ spec: description: Server specifies the URL of the target cluster's Kubernetes control plane API. type: string + required: + - defaultServiceAccount + - server type: object type: array destinations: diff --git a/manifests/install.yaml b/manifests/install.yaml index 868793d2f8e52..20f1941202c10 100644 --- a/manifests/install.yaml +++ b/manifests/install.yaml @@ -21735,7 +21735,7 @@ spec: sync operation. properties: defaultServiceAccount: - description: ServiceAccountName to be used for impersonation + description: DefaultServiceAccount to be used for impersonation during the sync operation type: string namespace: @@ -21746,6 +21746,9 @@ spec: description: Server specifies the URL of the target cluster's Kubernetes control plane API. type: string + required: + - defaultServiceAccount + - server type: object type: array destinations: diff --git a/pkg/apis/application/v1alpha1/generated.proto b/pkg/apis/application/v1alpha1/generated.proto index 0b79d47202cb9..0380e1a546d8d 100644 --- a/pkg/apis/application/v1alpha1/generated.proto +++ b/pkg/apis/application/v1alpha1/generated.proto @@ -156,7 +156,7 @@ message ApplicationDestinationServiceAccount { // Namespace specifies the target namespace for the application's resources. optional string namespace = 2; - // ServiceAccountName to be used for impersonation during the sync operation + // DefaultServiceAccount to be used for impersonation during the sync operation optional string defaultServiceAccount = 3; }