Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[knox]: change client struct #105

Merged
merged 8 commits into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading