Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

directly read key #87

Merged
merged 1 commit into from
Apr 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions flow/flow.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ var (
)

type Flow struct {
Env string
useApp bool
githubToken *string
githubAppID *int64
githubAppInstlationID *int64
githubAppPrivateKeyPath *string
Env string
useApp bool
githubToken *string
githubAppID *int64
githubAppInstlationID *int64
githubAppPrivateKey *string
}

func New(c *Config) (*Flow, error) {
Expand All @@ -31,7 +31,7 @@ func New(c *Config) (*Flow, error) {
githubToken := os.Getenv("FLOW_GITHUB_TOKEN")
githubAppID := os.Getenv("FLOW_GITHUB_APP_ID")
githubAppInstlationID := os.Getenv("FLOW_GITHUB_APP_INSTALLATION_ID")
githubAppPrivateKeyPath := os.Getenv("FLOW_GITHUB_APP_PRIVATE_KEY_PATH")
githubAppPrivateKey := os.Getenv("FLOW_GITHUB_APP_PRIVATE_KEY")

f.githubToken = &githubToken

Expand All @@ -50,7 +50,7 @@ func New(c *Config) (*Flow, error) {
}
f.githubAppInstlationID = &githubAppInstlationIDInt

f.githubAppPrivateKeyPath = &githubAppPrivateKeyPath
f.githubAppPrivateKey = &githubAppPrivateKey
}

if !f.useApp && f.githubToken == nil {
Expand Down
2 changes: 1 addition & 1 deletion flow/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func (f *Flow) processImage(ctx context.Context, image, version string) error {

func (f *Flow) getGitbotClient(ctx context.Context) *github.Client {
if f.useApp {
return gitbot.NewGitHubClientWithApp(ctx, *f.githubAppID, *f.githubAppInstlationID, *f.githubAppPrivateKeyPath)
return gitbot.NewGitHubClientWithApp(ctx, *f.githubAppID, *f.githubAppInstlationID, *f.githubAppPrivateKey)
}
return gitbot.NewGitHubClient(ctx, *f.githubToken)
}
Expand Down
4 changes: 2 additions & 2 deletions gitbot/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ func NewGitHubClient(ctx context.Context, token string) *github.Client {
return github.NewClient(tc)
}

func NewGitHubClientWithApp(ctx context.Context, appID, installationID int64, privateKeyPath string) *github.Client {
func NewGitHubClientWithApp(ctx context.Context, appID, installationID int64, privateKey string) *github.Client {
tr := http.DefaultTransport
itr, err := ghinstallation.NewKeyFromFile(tr, appID, installationID, privateKeyPath)
itr, err := ghinstallation.New(tr, appID, installationID, []byte(privateKey))
if err != nil {
log.Fatal(err)
}
Expand Down