Skip to content

Commit

Permalink
Update pkg/client.go
Browse files Browse the repository at this point in the history
Co-authored-by: Nick Floyd <139819+nickfloyd@users.noreply.github.com>
  • Loading branch information
kfcampbell and nickfloyd authored Jun 3, 2024
1 parent 9007016 commit 1a4d9fc
Showing 1 changed file with 17 additions and 18 deletions.
35 changes: 17 additions & 18 deletions pkg/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,24 +33,23 @@ func NewApiClient(optionFuncs ...ClientOptionFunc) (*Client, error) {
netHttpClient.Timeout = options.RequestTimeout
}

// Configure GitHub App authentication if required fields are provided
if (options.GitHubAppID != 0 || options.GitHubAppClientID != "") && options.GitHubAppInstallationID != 0 && options.GitHubAppPemFilePath != "" {
existingTransport := netHttpClient.Transport

if options.GitHubAppClientID != "" {
appTransport, err := ghinstallation.NewKeyFromFile(existingTransport, options.GitHubAppClientID, options.GitHubAppInstallationID, options.GitHubAppPemFilePath)
if err != nil {
return nil, fmt.Errorf("failed to create transport from GitHub App using clientID: %v", err)
}
netHttpClient.Transport = appTransport
} else {
appTransport, err := ghinstallation.NewKeyFromFileWithAppID(existingTransport, options.GitHubAppID, options.GitHubAppInstallationID, options.GitHubAppPemFilePath)
if err != nil {
return nil, fmt.Errorf("failed to create transport from GitHub App using appID: %v", err)
}
netHttpClient.Transport = appTransport
}
}
if (options.GitHubAppID != 0 || options.GitHubAppClientID != "") && options.GitHubAppInstallationID != 0 && options.GitHubAppPemFilePath != "" {
existingTransport := netHttpClient.Transport
var appTransport ghinstallation.Transport
var err error

if options.GitHubAppClientID != "" {
appTransport, err = ghinstallation.NewKeyFromFile(existingTransport, options.GitHubAppClientID, options.GitHubAppInstallationID, options.GitHubAppPemFilePath)

Check failure on line 42 in pkg/client.go

View workflow job for this annotation

GitHub Actions / lint

cannot use ghinstallation.NewKeyFromFile(existingTransport, options.GitHubAppClientID, options.GitHubAppInstallationID, options.GitHubAppPemFilePath) (value of type *ghinstallation.Transport) as ghinstallation.Transport value in assignment

Check failure on line 42 in pkg/client.go

View workflow job for this annotation

GitHub Actions / lint

cannot use ghinstallation.NewKeyFromFile(existingTransport, options.GitHubAppClientID, options.GitHubAppInstallationID, options.GitHubAppPemFilePath) (value of type *ghinstallation.Transport) as ghinstallation.Transport value in assignment

Check failure on line 42 in pkg/client.go

View workflow job for this annotation

GitHub Actions / lint

cannot use ghinstallation.NewKeyFromFile(existingTransport, options.GitHubAppClientID, options.GitHubAppInstallationID, options.GitHubAppPemFilePath) (value of type *ghinstallation.Transport) as ghinstallation.Transport value in assignment

Check failure on line 42 in pkg/client.go

View workflow job for this annotation

GitHub Actions / build

cannot use ghinstallation.NewKeyFromFile(existingTransport, options.GitHubAppClientID, options.GitHubAppInstallationID, options.GitHubAppPemFilePath) (value of type *ghinstallation.Transport) as ghinstallation.Transport value in assignment
} else {
appTransport, err = ghinstallation.NewKeyFromFileWithAppID(existingTransport, options.GitHubAppID, options.GitHubAppInstallationID, options.GitHubAppPemFilePath)

Check failure on line 44 in pkg/client.go

View workflow job for this annotation

GitHub Actions / lint

cannot use ghinstallation.NewKeyFromFileWithAppID(existingTransport, options.GitHubAppID, options.GitHubAppInstallationID, options.GitHubAppPemFilePath) (value of type *ghinstallation.Transport) as ghinstallation.Transport value in assignment

Check failure on line 44 in pkg/client.go

View workflow job for this annotation

GitHub Actions / lint

cannot use ghinstallation.NewKeyFromFileWithAppID(existingTransport, options.GitHubAppID, options.GitHubAppInstallationID, options.GitHubAppPemFilePath) (value of type *ghinstallation.Transport) as ghinstallation.Transport value in assignment

Check failure on line 44 in pkg/client.go

View workflow job for this annotation

GitHub Actions / build

cannot use ghinstallation.NewKeyFromFileWithAppID(existingTransport, options.GitHubAppID, options.GitHubAppInstallationID, options.GitHubAppPemFilePath) (value of type *ghinstallation.Transport) as ghinstallation.Transport value in assignment
}

if err != nil {
return nil, fmt.Errorf("failed to create transport from GitHub App: %v", err)
}

netHttpClient.Transport = appTransport

Check failure on line 51 in pkg/client.go

View workflow job for this annotation

GitHub Actions / lint

cannot use appTransport (variable of type ghinstallation.Transport) as http.RoundTripper value in assignment: ghinstallation.Transport does not implement http.RoundTripper (method RoundTrip has pointer receiver)) (typecheck)

Check failure on line 51 in pkg/client.go

View workflow job for this annotation

GitHub Actions / lint

cannot use appTransport (variable of type ghinstallation.Transport) as http.RoundTripper value in assignment: ghinstallation.Transport does not implement http.RoundTripper (method RoundTrip has pointer receiver)) (typecheck)

Check failure on line 51 in pkg/client.go

View workflow job for this annotation

GitHub Actions / build

cannot use appTransport (variable of type ghinstallation.Transport) as http.RoundTripper value in assignment: ghinstallation.Transport does not implement http.RoundTripper (method RoundTrip has pointer receiver)
}

// Middleware must be applied after App transport is set, otherwise App token will fail to be
// renewed with a 400 Bad Request error (even though the request is identical to a successful one.)
Expand Down

0 comments on commit 1a4d9fc

Please sign in to comment.