Skip to content

Commit

Permalink
fix: return error
Browse files Browse the repository at this point in the history
Signed-off-by: Edmund Ochieng <[email protected]>
  • Loading branch information
OchiengEd committed Aug 28, 2024
1 parent c71c493 commit c273967
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pkg/lib/scoped/token_retriever.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func (r *BearerTokenRetriever) Retrieve(reference *corev1.ObjectReference) (toke

if secret == nil {
err = fmt.Errorf("the service account does not have any API secret sa=%s/%s", sa.GetNamespace(), sa.GetName())
token = requestSAToken(r.kubeclient, sa)
token, _ = requestSAToken(r.kubeclient, sa)
if token != "" {
err = nil
}
Expand All @@ -55,16 +55,16 @@ func (r *BearerTokenRetriever) Retrieve(reference *corev1.ObjectReference) (toke

// requestSAToken requests for a service account token from the Kubernetes API server whenever the Operator
// Lifecycle manager is unable to find a service account token secret
func requestSAToken(kubeclient operatorclient.ClientInterface, sa *corev1.ServiceAccount) string {
func requestSAToken(kubeclient operatorclient.ClientInterface, sa *corev1.ServiceAccount) (string, error) {
req := new(authv1.TokenRequest)
req, err := kubeclient.KubernetesInterface().
CoreV1().ServiceAccounts(sa.GetNamespace()).
CreateToken(context.Background(), sa.GetName(), req, metav1.CreateOptions{})
if err != nil {
return ""
return "", err
}

return req.Status.Token
return req.Status.Token, nil
}

func getAPISecret(logger logrus.FieldLogger, kubeclient operatorclient.ClientInterface, sa *corev1.ServiceAccount) (APISecret *corev1.Secret, err error) {
Expand Down

0 comments on commit c273967

Please sign in to comment.