Forráskód Böngészése

github app client: don't hardcode secret path

Anukul Sangwan 4 éve
szülő
commit
2e7d6ebec1

+ 2 - 1
internal/integrations/ci/actions/actions.go

@@ -29,6 +29,7 @@ type GithubActions struct {
 
 	GithubConf           *oauth2.Config // one of these will let us authenticate
 	GithubAppID          int64
+	GithubAppSecretPath  string
 	GithubInstallationID uint
 
 	WebhookToken string
@@ -229,7 +230,7 @@ func (g *GithubActions) getClient() (*github.Client, error) {
 		http.DefaultTransport,
 		g.GithubAppID,
 		int64(g.GithubInstallationID),
-		"/porter/docker/github_app_private_key.pem")
+		g.GithubAppSecretPath)
 
 	if err != nil {
 		return nil, err

+ 1 - 0
server/api/deploy_handler.go

@@ -375,6 +375,7 @@ func (app *App) HandleUninstallTemplate(w http.ResponseWriter, r *http.Request)
 					ServerURL:              app.ServerConf.ServerURL,
 					GithubOAuthIntegration: gr,
 					GithubAppID:            app.GithubAppConf.AppID,
+					GithubAppSecretPath:    app.GithubAppConf.SecretPath,
 					GithubInstallationID:   gitAction.GithubInstallationID,
 					GitRepoName:            repoSplit[1],
 					GitRepoOwner:           repoSplit[0],

+ 1 - 0
server/api/git_action_handler.go

@@ -159,6 +159,7 @@ func (app *App) createGitActionFromForm(
 		ServerURL:              app.ServerConf.ServerURL,
 		GithubOAuthIntegration: nil,
 		GithubAppID:            app.GithubAppConf.AppID,
+		GithubAppSecretPath:    app.GithubAppConf.SecretPath,
 		GithubInstallationID:   form.GitRepoID,
 		GitRepoName:            repoSplit[1],
 		GitRepoOwner:           repoSplit[0],

+ 1 - 1
server/api/git_repo_handler.go

@@ -501,7 +501,7 @@ func (app *App) githubAppClientFromRequest(r *http.Request) (*github.Client, err
 		http.DefaultTransport,
 		app.GithubAppConf.AppID,
 		int64(installationID),
-		"/porter/docker/github_app_private_key.pem")
+		app.GithubAppConf.SecretPath)
 
 	if err != nil {
 		return nil, err

+ 2 - 0
server/api/release_handler.go

@@ -1102,6 +1102,7 @@ func (app *App) HandleUpgradeRelease(w http.ResponseWriter, r *http.Request) {
 					GithubOAuthIntegration: gr,
 					GithubInstallationID:   gitAction.GithubInstallationID,
 					GithubAppID:            app.GithubAppConf.AppID,
+					GithubAppSecretPath:    app.GithubAppConf.SecretPath,
 					GitRepoName:            repoSplit[1],
 					GitRepoOwner:           repoSplit[0],
 					Repo:                   *app.Repo,
@@ -1517,6 +1518,7 @@ func (app *App) HandleRollbackRelease(w http.ResponseWriter, r *http.Request) {
 					GithubOAuthIntegration: gr,
 					GithubInstallationID:   gitAction.GithubInstallationID,
 					GithubAppID:            app.GithubAppConf.AppID,
+					GithubAppSecretPath:    app.GithubAppConf.SecretPath,
 					GitRepoName:            repoSplit[1],
 					GitRepoOwner:           repoSplit[0],
 					Repo:                   *app.Repo,