From 23165fa489010f553bf7e19f9eb72e95fd52a821 Mon Sep 17 00:00:00 2001 From: Anuj Chaudhari Date: Wed, 10 Jul 2024 14:33:49 -0700 Subject: [PATCH] Make HubClient private --- client/hub/client.go | 16 ++++++++-------- client/hub/request.go | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/client/hub/client.go b/client/hub/client.go index f9089ffb..a7b49ea2 100644 --- a/client/hub/client.go +++ b/client/hub/client.go @@ -35,8 +35,8 @@ type Client interface { Subscribe(ctx context.Context, req *Request, handler EventResponseHandler) error } -// HubClient client to talk to Tanzu Hub through GraphQL APIs -type HubClient struct { +// hubClient client to talk to Tanzu Hub through GraphQL APIs +type hubClient struct { // contextName is Tanzu CLI context name contextName string @@ -45,25 +45,25 @@ type HubClient struct { httpClient *http.Client } -type ClientOptions func(o *HubClient) +type ClientOptions func(o *hubClient) // WithAccessToken creates the Client using the specified Access Token func WithAccessToken(token string) ClientOptions { - return func(c *HubClient) { + return func(c *hubClient) { c.accessToken = token } } // WithEndpoint creates the Client using the specified Endpoint func WithEndpoint(endpoint string) ClientOptions { - return func(c *HubClient) { + return func(c *hubClient) { c.tanzuHubEndpoint = endpoint } } // WithHTTPClient creates the Client using the specified HttpClient func WithHTTPClient(httpClient *http.Client) ClientOptions { - return func(c *HubClient) { + return func(c *hubClient) { c.httpClient = httpClient } } @@ -77,7 +77,7 @@ func WithHTTPClient(httpClient *http.Client) ClientOptions { // EXPERIMENTAL: Both the function's signature and implementation are subjected to change/removal // if an alternative means to provide equivalent functionality can be introduced. func NewClient(contextName string, opts ...ClientOptions) (Client, error) { - c := &HubClient{ + c := &hubClient{ contextName: contextName, } @@ -93,7 +93,7 @@ func NewClient(contextName string, opts ...ClientOptions) (Client, error) { return c, nil } -func (c *HubClient) initializeClient(contextName string) error { +func (c *hubClient) initializeClient(contextName string) error { var err error // Set accessToken if it is not already set diff --git a/client/hub/request.go b/client/hub/request.go index 80342110..6667550c 100644 --- a/client/hub/request.go +++ b/client/hub/request.go @@ -21,7 +21,7 @@ import ( // ctx context.Context: The context for the request. If provided, it will be used to cancel the request if the context is canceled. // req *Request: The GraphQL request to be sent. // responseData interface{}: The interface to store the response data. The response data will be unmarshaled into this interface. -func (c *HubClient) Request(ctx context.Context, req *Request, responseData interface{}) error { +func (c *hubClient) Request(ctx context.Context, req *Request, responseData interface{}) error { resp := &Response{Data: responseData} body, err := json.Marshal(req) @@ -65,7 +65,7 @@ func (c *HubClient) Request(ctx context.Context, req *Request, responseData inte // ctx context.Context: The context for the subscription. If provided, it will be used to cancel the subscription if the context is canceled. // req *Request: The GraphQL subscription request to be sent. // handler EventResponseHandler: The handler function to process incoming events. -func (c *HubClient) Subscribe(ctx context.Context, req *Request, handler EventResponseHandler) error { +func (c *hubClient) Subscribe(ctx context.Context, req *Request, handler EventResponseHandler) error { body, err := json.Marshal(req) if err != nil { return err