Let gh.NewGitHubClient return a pointer

This commit is contained in:
Bernd Ahlers
2024-03-06 10:17:09 +01:00
parent 5cb10b0a38
commit 40cd99abd4
2 changed files with 5 additions and 5 deletions

View File

@@ -125,7 +125,7 @@ func githubAppAccessTokenGenerateCommand(cmd *cobra.Command, args []string) {
fmt.Println(token)
}
func githubToggleRuleset(_ *cobra.Command, args []string, cb func(client gh.Client, owner, repo, ruleset string) (*gh.Ruleset, error)) error {
func githubToggleRuleset(_ *cobra.Command, args []string, cb func(client *gh.Client, owner, repo, ruleset string) (*gh.Ruleset, error)) error {
if len(args) != 2 {
return fmt.Errorf("expected two arguments")
}
@@ -160,13 +160,13 @@ func githubToggleRuleset(_ *cobra.Command, args []string, cb func(client gh.Clie
}
func githubEnableRuleset(cmd *cobra.Command, args []string) error {
return githubToggleRuleset(cmd, args, func(client gh.Client, owner, repo, ruleset string) (*gh.Ruleset, error) {
return githubToggleRuleset(cmd, args, func(client *gh.Client, owner, repo, ruleset string) (*gh.Ruleset, error) {
return client.EnableRulesetByName(owner, repo, ruleset)
})
}
func githubDisableRuleset(cmd *cobra.Command, args []string) error {
return githubToggleRuleset(cmd, args, func(client gh.Client, owner, repo, ruleset string) (*gh.Ruleset, error) {
return githubToggleRuleset(cmd, args, func(client *gh.Client, owner, repo, ruleset string) (*gh.Ruleset, error) {
return client.DisableRulesetByName(owner, repo, ruleset)
})
}

View File

@@ -78,12 +78,12 @@ func (gh *Client) DisableRulesetByName(owner string, repo string, rulesetName st
return gh.updateRulesetEnforcementByName(owner, repo, rulesetName, "disabled")
}
func NewGitHubClient(accessToken string) Client {
func NewGitHubClient(accessToken string) *Client {
tokenSource := oauth2.StaticTokenSource(&oauth2.Token{AccessToken: accessToken})
ctx := context.Background()
client := github.NewClient(oauth2.NewClient(ctx, tokenSource))
return Client{
return &Client{
client: client,
ctx: ctx,
}