Skip to content

Commit

Permalink
fix: auth token isn't mandatory for all services
Browse files Browse the repository at this point in the history
  • Loading branch information
adityathebe committed Nov 5, 2024
1 parent 87bc493 commit b0c0cf1
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions pkg/clients/git/connectors/git_access_token.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package connectors

import (
"fmt"
netHTTP "net/http"
"os"

"github.com/flanksource/commons/logger"
Expand Down Expand Up @@ -36,13 +37,12 @@ type GitAccessTokenClient struct {
func NewAccessTokenClient(service, owner, repoName, accessToken string) (Connector, error) {
logger.Infof("Creating %s client for %s/%s using access token: %s", service, owner, repoName, logger.PrintableSecret(accessToken))
scmClient, err := factory.NewClient(service, "", accessToken)
if err != nil {
return nil, err
}

if scmClient.Client == nil {
if accessToken == "" {
return nil, fmt.Errorf("unable to create %s client. missing access token", service)
}

return nil, fmt.Errorf("unable to create %s client for unknown reason", service)
scmClient.Client = netHTTP.DefaultClient
}

scmClient.Client.Transport = logger.NewHttpLogger(logger.GetLogger("git"), scmClient.Client.Transport)
Expand Down

0 comments on commit b0c0cf1

Please sign in to comment.