diff --git a/api/orb/client.go b/api/orb/client.go index 607398f8d..ab190ddf5 100644 --- a/api/orb/client.go +++ b/api/orb/client.go @@ -4,7 +4,6 @@ import ( "fmt" "io" "os" - "sync" "github.com/CircleCI-Public/circleci-cli/api" "github.com/CircleCI-Public/circleci-cli/api/graphql" @@ -12,12 +11,6 @@ import ( "github.com/pkg/errors" ) -var ( - once sync.Once - client Client - clientError error -) - type clientVersion string // ConfigResponse is a structure that matches the result of the GQL @@ -33,15 +26,7 @@ type Client interface { OrbQuery(configPath string, ownerId string) (*api.ConfigResponse, error) } -func GetClient(config *settings.Config) (Client, error) { - once.Do(func() { - client, clientError = newClient(config) - }) - - return client, clientError -} - -func newClient(config *settings.Config) (Client, error) { +func NewClient(config *settings.Config) (Client, error) { gql := graphql.NewClient(config.HTTPClient, config.Host, config.Endpoint, config.Token, config.Debug) clientVersion, err := detectClientVersion(gql) diff --git a/cmd/orb.go b/cmd/orb.go index cdacda85b..d7a011eb3 100644 --- a/cmd/orb.go +++ b/cmd/orb.go @@ -733,7 +733,7 @@ func validateOrb(opts orbOptions, org orbOrgOptions) error { return fmt.Errorf("failed to get the appropriate org-id: %s", err.Error()) } - client, err := orb.GetClient(opts.cfg) + client, err := orb.NewClient(opts.cfg) if err != nil { return errors.Wrap(err, "Getting orb client") } @@ -759,7 +759,7 @@ func processOrb(opts orbOptions, org orbOrgOptions) error { return fmt.Errorf("failed to get the appropriate org-id: %s", err.Error()) } - client, err := orb.GetClient(opts.cfg) + client, err := orb.NewClient(opts.cfg) if err != nil { return errors.Wrap(err, "Getting orb client") }