Skip to content

Commit

Permalink
Make HubClient private
Browse files Browse the repository at this point in the history
  • Loading branch information
anujc25 committed Jul 10, 2024
1 parent bda63fc commit 23165fa
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
16 changes: 8 additions & 8 deletions client/hub/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
}
}
Expand All @@ -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,
}

Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions client/hub/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 23165fa

Please sign in to comment.