From 2cc1ea7a88094eb56a91b801c869bb6a47c60f4c Mon Sep 17 00:00:00 2001 From: Youwen Zhu Date: Tue, 5 Mar 2024 14:35:29 -0800 Subject: [PATCH 1/8] change client struct --- client.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/client.go b/client.go index d1aa4e9..bbe0fbc 100644 --- a/client.go +++ b/client.go @@ -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. @@ -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, @@ -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" From 8cd152d93553566f9ef8fe28323b73d668050e34 Mon Sep 17 00:00:00 2001 From: Youwen Zhu Date: Tue, 5 Mar 2024 14:37:51 -0800 Subject: [PATCH 2/8] fix build --- cmd/dev_client/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/dev_client/main.go b/cmd/dev_client/main.go index 153a6f4..b40ef71 100644 --- a/cmd/dev_client/main.go +++ b/cmd/dev_client/main.go @@ -117,7 +117,7 @@ func main() { cli := &knox.HTTPClient{ KeyFolder: keyFolder, - UncachedClient: knox.UncachedHTTPClient{ + UncachedClient: &knox.UncachedHTTPClient{ Host: hostname, AuthHandler: authHandler, Client: &http.Client{Transport: &http.Transport{TLSClientConfig: tlsConfig}}, From 47c40af279062308810f1a00269656ca5efeca54 Mon Sep 17 00:00:00 2001 From: Youwen Zhu Date: Tue, 5 Mar 2024 14:40:10 -0800 Subject: [PATCH 3/8] fix fmt --- client.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client.go b/client.go index bbe0fbc..0588021 100644 --- a/client.go +++ b/client.go @@ -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. From 431d4a9691649bcc1c77bacfb6f46e7ccaba07f5 Mon Sep 17 00:00:00 2001 From: Youwen Zhu Date: Tue, 5 Mar 2024 15:17:54 -0800 Subject: [PATCH 4/8] use constructor in main --- cmd/dev_client/main.go | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/cmd/dev_client/main.go b/cmd/dev_client/main.go index b40ef71..8593e43 100644 --- a/cmd/dev_client/main.go +++ b/cmd/dev_client/main.go @@ -117,11 +117,7 @@ func main() { cli := &knox.HTTPClient{ KeyFolder: keyFolder, - UncachedClient: &knox.UncachedHTTPClient{ - Host: hostname, - AuthHandler: authHandler, - Client: &http.Client{Transport: &http.Transport{TLSClientConfig: tlsConfig}}, - }, + UncachedClient: knox.NewUncachedClient(hostname, authHandler, &http.Client{Transport: &http.Transport{TLSClientConfig: tlsConfig}}) } loginCommand := client.NewLoginCommand(clientID, tokenEndpoint, "", "", "", "") From 2c68468d8c672073853d7b3a8521dfe1a6b07aa5 Mon Sep 17 00:00:00 2001 From: Youwen Zhu Date: Tue, 5 Mar 2024 15:19:13 -0800 Subject: [PATCH 5/8] fix build --- cmd/dev_client/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/dev_client/main.go b/cmd/dev_client/main.go index 8593e43..80443b4 100644 --- a/cmd/dev_client/main.go +++ b/cmd/dev_client/main.go @@ -117,7 +117,7 @@ func main() { cli := &knox.HTTPClient{ KeyFolder: keyFolder, - UncachedClient: knox.NewUncachedClient(hostname, authHandler, &http.Client{Transport: &http.Transport{TLSClientConfig: tlsConfig}}) + UncachedClient: knox.NewUncachedClient(hostname, authHandler, &http.Client{Transport: &http.Transport{TLSClientConfig: tlsConfig}}), } loginCommand := client.NewLoginCommand(clientID, tokenEndpoint, "", "", "", "") From 83a58b08a8bb5a3d7ad69235cabb3647ddbd005b Mon Sep 17 00:00:00 2001 From: Youwen Zhu Date: Tue, 5 Mar 2024 15:21:27 -0800 Subject: [PATCH 6/8] fix build --- cmd/dev_client/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/dev_client/main.go b/cmd/dev_client/main.go index 80443b4..36fab52 100644 --- a/cmd/dev_client/main.go +++ b/cmd/dev_client/main.go @@ -117,7 +117,7 @@ func main() { cli := &knox.HTTPClient{ KeyFolder: keyFolder, - UncachedClient: knox.NewUncachedClient(hostname, authHandler, &http.Client{Transport: &http.Transport{TLSClientConfig: tlsConfig}}), + UncachedClient: knox.NewUncachedClient(hostname, authHandler, &http.Client{Transport: &http.Transport{TLSClientConfig: tlsConfig}},""), } loginCommand := client.NewLoginCommand(clientID, tokenEndpoint, "", "", "", "") From a6168c86777bfceb5b0a13dfb0cd23747382b87d Mon Sep 17 00:00:00 2001 From: Youwen Zhu Date: Tue, 5 Mar 2024 15:26:48 -0800 Subject: [PATCH 7/8] Fix build --- cmd/dev_client/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/dev_client/main.go b/cmd/dev_client/main.go index 36fab52..89eee1d 100644 --- a/cmd/dev_client/main.go +++ b/cmd/dev_client/main.go @@ -117,7 +117,7 @@ func main() { cli := &knox.HTTPClient{ KeyFolder: keyFolder, - UncachedClient: knox.NewUncachedClient(hostname, authHandler, &http.Client{Transport: &http.Transport{TLSClientConfig: tlsConfig}},""), + UncachedClient: knox.NewUncachedClient(hostname, &http.Client{Transport: &http.Transport{TLSClientConfig: tlsConfig}}, authHandler, ""), } loginCommand := client.NewLoginCommand(clientID, tokenEndpoint, "", "", "", "") From f924c05592c92146e8a6c78b59686e4a8dcdacf0 Mon Sep 17 00:00:00 2001 From: Youwen Zhu Date: Tue, 5 Mar 2024 15:29:34 -0800 Subject: [PATCH 8/8] fix fmt --- cmd/dev_client/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/dev_client/main.go b/cmd/dev_client/main.go index 89eee1d..5f3cb14 100644 --- a/cmd/dev_client/main.go +++ b/cmd/dev_client/main.go @@ -116,7 +116,7 @@ func main() { } cli := &knox.HTTPClient{ - KeyFolder: keyFolder, + KeyFolder: keyFolder, UncachedClient: knox.NewUncachedClient(hostname, &http.Client{Transport: &http.Transport{TLSClientConfig: tlsConfig}}, authHandler, ""), }