Skip to content

Commit 06eb85a

Browse files
committed
pass sa name , ns and original error
Signed-off-by: rashmi_kh <[email protected]>
1 parent 2f9d96b commit 06eb85a

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

internal/authentication/tokengetter.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func (e *ServiceAccountNotFoundError) Unwrap() error {
3333

3434
// Error implements the error interface for ServiceAccountNotFoundError.
3535
func (e *ServiceAccountNotFoundError) Error() string {
36-
return fmt.Sprintf("service account %q not found in namespace %q: unable to authenticate with the Kubernetes cluster.", e.ServiceAccountName, e.ServiceAccountNamespace)
36+
return fmt.Sprintf("service account \"%s\" not found in namespace \"%s\": unable to authenticate with the Kubernetes cluster. (%s)", e.ServiceAccountName, e.ServiceAccountNamespace, e.Err.Error())
3737
}
3838

3939
type TokenGetterOption func(*TokenGetter)

internal/controllers/clusterextension_controller_test.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -336,8 +336,11 @@ func TestClusterExtensionResolutionAndUnpackSuccessfulApplierFails(t *testing.T)
336336
func TestClusterExtensionServiceAccountNotFound(t *testing.T) {
337337
cl, reconciler := newClientAndReconciler(t)
338338
reconciler.InstalledBundleGetter = &MockInstalledBundleGetter{
339-
err: &authentication.ServiceAccountNotFoundError{}, // Simulate missing SA
340-
}
339+
err: &authentication.ServiceAccountNotFoundError{
340+
ServiceAccountName: "missing-sa",
341+
ServiceAccountNamespace: "default",
342+
Err: errors.New("error from k8s api"),
343+
}}
341344

342345
ctx := context.Background()
343346
extKey := types.NamespacedName{Name: fmt.Sprintf("cluster-extension-test-%s", rand.String(8))}
@@ -374,7 +377,8 @@ func TestClusterExtensionServiceAccountNotFound(t *testing.T) {
374377
installedCond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1.TypeInstalled)
375378
require.NotNil(t, installedCond)
376379
require.Equal(t, metav1.ConditionUnknown, installedCond.Status)
377-
require.Contains(t, installedCond.Message, "unable to authenticate with the Kubernetes cluster")
380+
require.Contains(t, installedCond.Message, fmt.Sprintf("service account %q not found in namespace %q: unable to authenticate with the Kubernetes cluster. (%s)",
381+
"missing-sa", "default", "error from k8s api"))
378382

379383
progressingCond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1.TypeProgressing)
380384
require.NotNil(t, progressingCond)

0 commit comments

Comments
 (0)