Skip to content

Commit

Permalink
gofmt
Browse files Browse the repository at this point in the history
  • Loading branch information
yoyouwen committed Feb 29, 2024
1 parent fbbf405 commit 4a06ff6
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 13 deletions.
12 changes: 5 additions & 7 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand All @@ -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.
Expand Down Expand Up @@ -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 {
Expand All @@ -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}}},

Check failure

Code scanning / CodeQL

Disabled TLS certificate check High

InsecureSkipVerify should not be used in production code.
Version: "mock",
},
}
}
4 changes: 2 additions & 2 deletions client/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions client/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import (
"encoding/json"
"fmt"
"path"
"reflect"
"strconv"
"time"
"reflect"
)

func init() {
Expand Down Expand Up @@ -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}
Expand Down
2 changes: 1 addition & 1 deletion cmd/dev_client/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func main() {
}

cli := &knox.HTTPClient{
KeyFolder: keyFolder,
KeyFolder: keyFolder,
UncachedClient: knox.UncachedHTTPClient{
Host: hostname,
AuthHandler: authHandler,
Expand Down

0 comments on commit 4a06ff6

Please sign in to comment.