mirror of
https://github.com/Graylog2/graylog-project-cli.git
synced 2026-03-13 08:02:57 +08:00
Let gh.NewGitHubClient return a pointer
This commit is contained in:
@@ -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)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user