Skip to content

Commit

Permalink
Merge pull request #103 from whywaita/fix/gh-enterprise-endpoint
Browse files Browse the repository at this point in the history
GenerateGitHubAppsToken needs a GitHub Apps client
  • Loading branch information
whywaita authored Sep 22, 2021
2 parents 4f4b419 + dc29ad7 commit 9e3f92e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pkg/web/target.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ var (
GHListRunnersFunc = gh.ListRunners
GHIsInstalledGitHubApp = gh.IsInstalledGitHubApp
GHGenerateGitHubAppsToken = gh.GenerateGitHubAppsToken
GHNewClientInstallation = gh.NewClientInstallation
GHNewClientApps = gh.NewClientGitHubApps
)

func toNullString(input string) sql.NullString {
Expand Down
8 changes: 4 additions & 4 deletions pkg/web/target_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ func handleTargetCreate(w http.ResponseWriter, r *http.Request, ds datastore.Dat
return
}

clientInstallations, err := GHNewClientInstallation(inputTarget.GHEDomain, installationID)
clientApps, err := GHNewClientApps(inputTarget.GHEDomain)
if err != nil {
logger.Logf(false, "failed to client of GitHub Apps installation: %+v", err)
outputErrorMsg(w, http.StatusInternalServerError, "failed to client GitHub Apps client")
logger.Logf(false, "failed to client of GitHub Apps: %+v", err)
outputErrorMsg(w, http.StatusInternalServerError, "failed to client GitHub Apps")
return
}
token, expiredAt, err := GHGenerateGitHubAppsToken(ctx, clientInstallations, installationID)
token, expiredAt, err := GHGenerateGitHubAppsToken(ctx, clientApps, installationID)
if err != nil {
logger.Logf(false, "failed to generate GitHub Apps Token: %+v", err)
outputErrorMsg(w, http.StatusInternalServerError, "failed to generate GitHub Apps token")
Expand Down
2 changes: 1 addition & 1 deletion pkg/web/target_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func setStubFunctions() {
return testGitHubAppToken, &testTime, nil
}

web.GHNewClientInstallation = func(gheDomain string, installationID int64) (*github.Client, error) {
web.GHNewClientApps = func(gheDomain string) (*github.Client, error) {
return &github.Client{}, nil
}
}
Expand Down

0 comments on commit 9e3f92e

Please sign in to comment.