Skip to content

Commit

Permalink
Merge pull request #87 from ubie-oss/directly-read-key
Browse files Browse the repository at this point in the history
directly read key
  • Loading branch information
sakajunquality authored Apr 26, 2024
2 parents 40bd23d + f8f7dba commit f16802d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
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

0 comments on commit f16802d

Please sign in to comment.