diff --git a/pkg/cmd/auth/login/login.go b/pkg/cmd/auth/login/login.go index f92e6e7f3..d923870ed 100644 --- a/pkg/cmd/auth/login/login.go +++ b/pkg/cmd/auth/login/login.go @@ -16,7 +16,7 @@ import ( "github.com/cli/cli/internal/config" "github.com/cli/cli/internal/ghinstance" "github.com/cli/cli/internal/run" - "github.com/cli/cli/pkg/cmd/auth/client" + "github.com/cli/cli/pkg/cmd/auth/shared" "github.com/cli/cli/pkg/cmdutil" "github.com/cli/cli/pkg/iostreams" "github.com/cli/cli/pkg/prompt" @@ -138,7 +138,7 @@ func loginRun(opts *LoginOptions) error { return err } - err = client.ValidateHostCfg(opts.Hostname, cfg) + err = shared.ValidateHostCfg(opts.Hostname, cfg) if err != nil { return err } @@ -182,9 +182,9 @@ func loginRun(opts *LoginOptions) error { existingToken, _ := cfg.Get(hostname, "oauth_token") if existingToken != "" && opts.Interactive { - err := client.ValidateHostCfg(hostname, cfg) + err := shared.ValidateHostCfg(hostname, cfg) if err == nil { - apiClient, err := client.ClientFromCfg(hostname, cfg) + apiClient, err := shared.ClientFromCfg(hostname, cfg) if err != nil { return err } @@ -258,7 +258,7 @@ func loginRun(opts *LoginOptions) error { return err } - err = client.ValidateHostCfg(hostname, cfg) + err = shared.ValidateHostCfg(hostname, cfg) if err != nil { return err } @@ -294,7 +294,7 @@ func loginRun(opts *LoginOptions) error { if userValidated { username, _ = cfg.Get(hostname, "user") } else { - apiClient, err := client.ClientFromCfg(hostname, cfg) + apiClient, err := shared.ClientFromCfg(hostname, cfg) if err != nil { return err } diff --git a/pkg/cmd/auth/login/login_test.go b/pkg/cmd/auth/login/login_test.go index c41626939..1c33dfcc2 100644 --- a/pkg/cmd/auth/login/login_test.go +++ b/pkg/cmd/auth/login/login_test.go @@ -8,7 +8,7 @@ import ( "github.com/cli/cli/api" "github.com/cli/cli/internal/config" - "github.com/cli/cli/pkg/cmd/auth/client" + "github.com/cli/cli/pkg/cmd/auth/shared" "github.com/cli/cli/pkg/cmdutil" "github.com/cli/cli/pkg/httpmock" "github.com/cli/cli/pkg/iostreams" @@ -262,11 +262,11 @@ func Test_loginRun_nontty(t *testing.T) { tt.opts.IO = io t.Run(tt.name, func(t *testing.T) { reg := &httpmock.Registry{} - origClientFromCfg := client.ClientFromCfg + origClientFromCfg := shared.ClientFromCfg defer func() { - client.ClientFromCfg = origClientFromCfg + shared.ClientFromCfg = origClientFromCfg }() - client.ClientFromCfg = func(_ string, _ config.Config) (*api.Client, error) { + shared.ClientFromCfg = func(_ string, _ config.Config) (*api.Client, error) { httpClient := &http.Client{Transport: reg} return api.NewClientFromHTTP(httpClient), nil } @@ -429,11 +429,11 @@ func Test_loginRun_Survey(t *testing.T) { t.Run(tt.name, func(t *testing.T) { reg := &httpmock.Registry{} - origClientFromCfg := client.ClientFromCfg + origClientFromCfg := shared.ClientFromCfg defer func() { - client.ClientFromCfg = origClientFromCfg + shared.ClientFromCfg = origClientFromCfg }() - client.ClientFromCfg = func(_ string, _ config.Config) (*api.Client, error) { + shared.ClientFromCfg = func(_ string, _ config.Config) (*api.Client, error) { httpClient := &http.Client{Transport: reg} return api.NewClientFromHTTP(httpClient), nil } diff --git a/pkg/cmd/auth/client/client.go b/pkg/cmd/auth/shared/client.go similarity index 98% rename from pkg/cmd/auth/client/client.go rename to pkg/cmd/auth/shared/client.go index bacde0b82..217254237 100644 --- a/pkg/cmd/auth/client/client.go +++ b/pkg/cmd/auth/shared/client.go @@ -1,4 +1,4 @@ -package client +package shared import ( "fmt" diff --git a/pkg/cmd/auth/status/status_test.go b/pkg/cmd/auth/status/status_test.go index 0de14d388..6974770dc 100644 --- a/pkg/cmd/auth/status/status_test.go +++ b/pkg/cmd/auth/status/status_test.go @@ -8,7 +8,7 @@ import ( "github.com/cli/cli/api" "github.com/cli/cli/internal/config" - "github.com/cli/cli/pkg/cmd/auth/client" + "github.com/cli/cli/pkg/cmd/auth/shared" "github.com/cli/cli/pkg/cmdutil" "github.com/cli/cli/pkg/httpmock" "github.com/cli/cli/pkg/iostreams" @@ -217,11 +217,11 @@ func Test_statusRun(t *testing.T) { } reg := &httpmock.Registry{} - origClientFromCfg := client.ClientFromCfg + origClientFromCfg := shared.ClientFromCfg defer func() { - client.ClientFromCfg = origClientFromCfg + shared.ClientFromCfg = origClientFromCfg }() - client.ClientFromCfg = func(_ string, _ config.Config) (*api.Client, error) { + shared.ClientFromCfg = func(_ string, _ config.Config) (*api.Client, error) { httpClient := &http.Client{Transport: reg} return api.NewClientFromHTTP(httpClient), nil }