Rename auth/client to auth/shared

This commit is contained in:
Mislav Marohnić 2020-12-07 17:07:45 +01:00
parent d56d92c908
commit c39dc28fa1
4 changed files with 18 additions and 18 deletions

View file

@ -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
}

View file

@ -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
}

View file

@ -1,4 +1,4 @@
package client
package shared
import (
"fmt"

View file

@ -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
}