Skip to content

Commit

Permalink
sa not found
Browse files Browse the repository at this point in the history
Signed-off-by: rashmi_kh <rashmi.khanna@in.ibm.com>
  • Loading branch information
rashmi43 committed Nov 18, 2024
1 parent e87203a commit 157cce0
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions internal/authentication/tokengetter.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package authentication

import (
"fmt"
"context"
"sync"
"time"
Expand All @@ -9,6 +10,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
corev1 "k8s.io/client-go/kubernetes/typed/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/utils/ptr"
)

Expand Down Expand Up @@ -86,6 +88,10 @@ func (t *TokenGetter) getToken(ctx context.Context, key types.NamespacedName) (*
Spec: authenticationv1.TokenRequestSpec{ExpirationSeconds: ptr.To(int64(t.expirationDuration / time.Second))},
}, metav1.CreateOptions{})
if err != nil {
if errors.IsNotFound(err) {
var saNotFoundError = fmt.Errorf("service account not found")
return nil, saNotFoundError
}
return nil, err
}
return &req.Status, nil
Expand Down

0 comments on commit 157cce0

Please sign in to comment.