Skip to content

Commit 0a91669

Browse files
authored
[knox]: change client struct (#105)
* change client struct * fix build * fix fmt * use constructor in main * fix build * fix build * Fix build * fix fmt
1 parent b584dfb commit 0a91669

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

client.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ type HTTPClient struct {
198198
// KeyFolder is the location of cached keys on the file system. If empty, does not check for cached keys.
199199
KeyFolder string
200200
// Client is the http client for making network calls
201-
UncachedClient UncachedHTTPClient
201+
UncachedClient *UncachedHTTPClient
202202
}
203203

204204
// NewClient creates a new client to connect to talk to Knox.
@@ -343,8 +343,8 @@ type UncachedHTTPClient struct {
343343
}
344344

345345
// NewClient creates a new uncached client to connect to talk to Knox.
346-
func NewUncachedClient(host string, client HTTP, authHandler func() string, version string) UncachedHTTPClient {
347-
return UncachedHTTPClient{
346+
func NewUncachedClient(host string, client HTTP, authHandler func() string, version string) *UncachedHTTPClient {
347+
return &UncachedHTTPClient{
348348
Host: host,
349349
Client: client,
350350
AuthHandler: authHandler,
@@ -543,7 +543,7 @@ func getHTTPResp(cli HTTP, r *http.Request, resp *Response) error {
543543
func MockClient(host, keyFolder string) *HTTPClient {
544544
return &HTTPClient{
545545
KeyFolder: keyFolder,
546-
UncachedClient: UncachedHTTPClient{
546+
UncachedClient: &UncachedHTTPClient{
547547
Host: host,
548548
AuthHandler: func() string {
549549
return "TESTAUTH"

cmd/dev_client/main.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,8 @@ func main() {
116116
}
117117

118118
cli := &knox.HTTPClient{
119-
KeyFolder: keyFolder,
120-
UncachedClient: knox.UncachedHTTPClient{
121-
Host: hostname,
122-
AuthHandler: authHandler,
123-
Client: &http.Client{Transport: &http.Transport{TLSClientConfig: tlsConfig}},
124-
},
119+
KeyFolder: keyFolder,
120+
UncachedClient: knox.NewUncachedClient(hostname, &http.Client{Transport: &http.Transport{TLSClientConfig: tlsConfig}}, authHandler, ""),
125121
}
126122

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

0 commit comments

Comments
 (0)