Skip to content

Commit

Permalink
[knox]: change client struct (#105)
Browse files Browse the repository at this point in the history
* change client struct

* fix build

* fix fmt

* use constructor in main

* fix build

* fix build

* Fix build

* fix fmt
  • Loading branch information
yoyouwen authored Mar 6, 2024
1 parent b584dfb commit 0a91669
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
8 changes: 4 additions & 4 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ type HTTPClient struct {
// KeyFolder is the location of cached keys on the file system. If empty, does not check for cached keys.
KeyFolder string
// Client is the http client for making network calls
UncachedClient UncachedHTTPClient
UncachedClient *UncachedHTTPClient
}

// NewClient creates a new client to connect to talk to Knox.
Expand Down Expand Up @@ -343,8 +343,8 @@ type UncachedHTTPClient struct {
}

// NewClient creates a new uncached client to connect to talk to Knox.
func NewUncachedClient(host string, client HTTP, authHandler func() string, version string) UncachedHTTPClient {
return UncachedHTTPClient{
func NewUncachedClient(host string, client HTTP, authHandler func() string, version string) *UncachedHTTPClient {
return &UncachedHTTPClient{
Host: host,
Client: client,
AuthHandler: authHandler,
Expand Down Expand Up @@ -543,7 +543,7 @@ func getHTTPResp(cli HTTP, r *http.Request, resp *Response) error {
func MockClient(host, keyFolder string) *HTTPClient {
return &HTTPClient{
KeyFolder: keyFolder,
UncachedClient: UncachedHTTPClient{
UncachedClient: &UncachedHTTPClient{
Host: host,
AuthHandler: func() string {
return "TESTAUTH"
Expand Down
8 changes: 2 additions & 6 deletions cmd/dev_client/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,8 @@ func main() {
}

cli := &knox.HTTPClient{
KeyFolder: keyFolder,
UncachedClient: knox.UncachedHTTPClient{
Host: hostname,
AuthHandler: authHandler,
Client: &http.Client{Transport: &http.Transport{TLSClientConfig: tlsConfig}},
},
KeyFolder: keyFolder,
UncachedClient: knox.NewUncachedClient(hostname, &http.Client{Transport: &http.Transport{TLSClientConfig: tlsConfig}}, authHandler, ""),
}

loginCommand := client.NewLoginCommand(clientID, tokenEndpoint, "", "", "", "")
Expand Down

0 comments on commit 0a91669

Please sign in to comment.