From 40cd99abd49d323a8983f620dcf18bd96742eeec Mon Sep 17 00:00:00 2001 From: Bernd Ahlers Date: Wed, 6 Mar 2024 10:17:09 +0100 Subject: [PATCH] Let gh.NewGitHubClient return a pointer --- cmd/github.go | 6 +++--- gh/github.go | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cmd/github.go b/cmd/github.go index e6139da..cc5eb0a 100644 --- a/cmd/github.go +++ b/cmd/github.go @@ -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) }) } diff --git a/gh/github.go b/gh/github.go index 119e321..4abfa3e 100644 --- a/gh/github.go +++ b/gh/github.go @@ -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, }