From 385c42e6e826df99e1c98c5efea90c6129a4f255 Mon Sep 17 00:00:00 2001 From: Zachary Scott Date: Tue, 12 Jun 2018 17:59:05 +0900 Subject: [PATCH] We can access the logger from config so no need to pass it around --- client/client.go | 9 +++------ cmd/query.go | 2 +- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/client/client.go b/client/client.go index 299140a82..41612f1bf 100644 --- a/client/client.go +++ b/client/client.go @@ -3,7 +3,7 @@ package client import ( "context" - "github.com/circleci/circleci-cli/logger" + "github.com/circleci/circleci-cli/config" "github.com/machinebox/graphql" ) @@ -12,18 +12,15 @@ type Client struct { endpoint string token string client *graphql.Client - logger *logger.Logger } // NewClient returns a reference to a Client. // We also call graphql.NewClient to initialize a new GraphQL Client. -// Then we pass the Logger originally constructed as cmd.Logger. -func NewClient(endpoint string, token string, logger *logger.Logger) *Client { +func NewClient(endpoint string, token string) *Client { return &Client{ endpoint, token, graphql.NewClient(endpoint), - logger, } } @@ -37,7 +34,7 @@ func (c *Client) Run(query string) (map[string]interface{}, error) { ctx := context.Background() var resp map[string]interface{} - c.logger.Debug("Querying %s with:\n\n%s\n\n", c.endpoint, query) + config.Logger.Debug("Querying %s with:\n\n%s\n\n", c.endpoint, query) err := c.client.Run(ctx, req, &resp) return resp, err } diff --git a/cmd/query.go b/cmd/query.go index 47e795a0f..7c51b6b04 100644 --- a/cmd/query.go +++ b/cmd/query.go @@ -18,7 +18,7 @@ var queryCmd = &cobra.Command{ } func query(cmd *cobra.Command, args []string) { - client := client.NewClient(viper.GetString("endpoint"), viper.GetString("token"), config.Logger) + client := client.NewClient(viper.GetString("endpoint"), viper.GetString("token")) query, err := ioutil.ReadAll(os.Stdin) config.Logger.FatalOnError("Something happened", err)