Skip to content

Commit

Permalink
chore: Callback Web Server Address Flag
Browse files Browse the repository at this point in the history
  • Loading branch information
otaviof committed Dec 5, 2024
1 parent 42162b5 commit ff69197
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pkg/githubapp/githubapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ type GitHubApp struct {

gitHubURL string // GitHub API URL
gitHubOrgName string // GitHub organization name
webServerAddr string // local webserver address
webServerPort int // local webserver port
}

Expand All @@ -43,6 +44,8 @@ func (g *GitHubApp) PersistentFlags(p *pflag.FlagSet) {
"GitHub URL")
p.StringVar(&g.gitHubOrgName, "org", g.gitHubOrgName,
"GitHub organization name")
p.StringVar(&g.webServerAddr, "webserver-addr", g.webServerAddr,
"Callback webserver listen address")
p.IntVar(&g.webServerPort, "webserver-port", g.webServerPort,
"Callback webserver port number")
}
Expand Down Expand Up @@ -136,7 +139,7 @@ func (g *GitHubApp) oAuth2Workflow(
})

webServer := &http.Server{
Addr: fmt.Sprintf("127.0.0.1:%d", g.webServerPort),
Addr: fmt.Sprintf("%s:%d", g.webServerAddr, g.webServerPort),
Handler: serveMux,
}
// Opening the web browser while listening for the GitHub callback URL in the
Expand Down Expand Up @@ -198,6 +201,7 @@ func NewGitHubApp(logger *slog.Logger) *GitHubApp {
return &GitHubApp{
logger: logger,
gitHubURL: defaultPublicGitHubURL,
webServerAddr: "127.0.0.1",
webServerPort: 8228,
}
}

0 comments on commit ff69197

Please sign in to comment.