From 4a06ff6ce814d3637fe36690dce9c7a6ad192ced Mon Sep 17 00:00:00 2001 From: Youwen Zhu Date: Thu, 29 Feb 2024 11:13:02 -0800 Subject: [PATCH] gofmt --- client.go | 12 +++++------- client/command.go | 4 ++-- client/register.go | 6 +++--- cmd/dev_client/main.go | 2 +- 4 files changed, 11 insertions(+), 13 deletions(-) diff --git a/client.go b/client.go index 9e84ff8..d1aa4e9 100644 --- a/client.go +++ b/client.go @@ -204,7 +204,7 @@ type HTTPClient struct { // NewClient creates a new client to connect to talk to Knox. func NewClient(host string, client HTTP, authHandler func() string, keyFolder, version string) APIClient { return &HTTPClient{ - KeyFolder: keyFolder, + KeyFolder: keyFolder, UncachedClient: NewUncachedClient(host, client, authHandler, version), } } @@ -330,7 +330,6 @@ func (c *HTTPClient) getHTTPData(method string, path string, body url.Values, da return c.UncachedClient.getHTTPData(method, path, body, data) } - // UncachedHTTPClient is a client that uses HTTP to talk to Knox without caching. type UncachedHTTPClient struct { // Host is used as the host for http connections @@ -376,7 +375,7 @@ func (c *UncachedHTTPClient) CacheGetKey(keyID string) (*Key, error) { // GetKey gets a knox key by keyID. func (c *UncachedHTTPClient) GetKey(keyID string) (*Key, error) { - return c.NetworkGetKey(keyID) + return c.NetworkGetKey(keyID) } // CacheGetKeyWithStatus acts same as NetworkGetKeyWithStatus for UncachedHTTPClient. @@ -399,7 +398,7 @@ func (c *UncachedHTTPClient) NetworkGetKeyWithStatus(keyID string, status Versio // GetKeyWithStatus gets a knox key by keyID and status (no cache). func (c *UncachedHTTPClient) GetKeyWithStatus(keyID string, status VersionStatus) (*Key, error) { - return c.NetworkGetKeyWithStatus(keyID, status) + return c.NetworkGetKeyWithStatus(keyID, status) } // CreateKey creates a knox key with given keyID data and ACL. @@ -529,7 +528,6 @@ func (c *UncachedHTTPClient) getHTTPData(method string, path string, body url.Va return nil } - func getHTTPResp(cli HTTP, r *http.Request, resp *Response) error { w, err := cli.Do(r) if err != nil { @@ -550,8 +548,8 @@ func MockClient(host, keyFolder string) *HTTPClient { AuthHandler: func() string { return "TESTAUTH" }, - Client: &http.Client{Transport: &http.Transport{TLSClientConfig: &tls.Config{InsecureSkipVerify: true}}}, - Version: "mock", + Client: &http.Client{Transport: &http.Transport{TLSClientConfig: &tls.Config{InsecureSkipVerify: true}}}, + Version: "mock", }, } } diff --git a/client/command.go b/client/command.go index f838a59..2c136e0 100644 --- a/client/command.go +++ b/client/command.go @@ -68,8 +68,8 @@ var clientGetKeyMetrics = func(map[string]string) {} func Run( client knox.APIClient, p *VisibilityParams, - loginCommand *Command, - ) { + loginCommand *Command, +) { cli = client if p != nil { diff --git a/client/register.go b/client/register.go index d6a66b6..aa77d32 100644 --- a/client/register.go +++ b/client/register.go @@ -4,9 +4,9 @@ import ( "encoding/json" "fmt" "path" + "reflect" "strconv" "time" - "reflect" ) func init() { @@ -58,10 +58,10 @@ func parseTimeout(val string) (time.Duration, error) { } func runRegister(cmd *Command, args []string) *ErrorStatus { - if reflect.TypeOf(cli).Name() == "UncachedHTTPClient" { + if reflect.TypeOf(cli).Name() == "UncachedHTTPClient" { fmt.Println("Cannot Register in No Cache mode") return nil - } + } timeout, err := parseTimeout(*registerTimeout) if err != nil { return &ErrorStatus{fmt.Errorf("Invalid value for timeout flag: %s", err.Error()), false} diff --git a/cmd/dev_client/main.go b/cmd/dev_client/main.go index 1bf153d..153a6f4 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.UncachedHTTPClient{ Host: hostname, AuthHandler: authHandler,