Fix more golint warnings.
authorWard Vandewege <ward@curii.com>
Sun, 25 Oct 2020 00:28:04 +0000 (20:28 -0400)
committerWard Vandewege <ward@curii.com>
Sun, 25 Oct 2020 00:28:04 +0000 (20:28 -0400)
No issue #

Arvados-DCO-1.1-Signed-off-by: Ward Vandewege <ward@curii.com>

lib/controller/fed_collections.go
lib/controller/fed_containers.go
lib/controller/fed_generic.go
sdk/go/arvados/client.go
sdk/go/keepclient/keepclient.go
sdk/go/keepclient/support.go
services/keepproxy/keepproxy.go

index c33f5b28946ab430e8532195c50c8ff8ac478506..a0a123129fdacdae34bf8b216d3e6b766a6f5889 100644 (file)
@@ -157,7 +157,7 @@ type searchRemoteClusterForPDH struct {
 func fetchRemoteCollectionByUUID(
        h *genericFederatedRequestHandler,
        effectiveMethod string,
-       clusterId *string,
+       clusterID *string,
        uuid string,
        remainder string,
        w http.ResponseWriter,
@@ -170,11 +170,11 @@ func fetchRemoteCollectionByUUID(
 
        if uuid != "" {
                // Collection UUID GET request
-               *clusterId = uuid[0:5]
-               if *clusterId != "" && *clusterId != h.handler.Cluster.ClusterID {
+               *clusterID = uuid[0:5]
+               if *clusterID != "" && *clusterID != h.handler.Cluster.ClusterID {
                        // request for remote collection by uuid
-                       resp, err := h.handler.remoteClusterRequest(*clusterId, req)
-                       newResponse, err := rewriteSignatures(*clusterId, "", resp, err)
+                       resp, err := h.handler.remoteClusterRequest(*clusterID, req)
+                       newResponse, err := rewriteSignatures(*clusterID, "", resp, err)
                        h.handler.proxy.ForwardResponse(w, newResponse, err)
                        return true
                }
@@ -186,7 +186,7 @@ func fetchRemoteCollectionByUUID(
 func fetchRemoteCollectionByPDH(
        h *genericFederatedRequestHandler,
        effectiveMethod string,
-       clusterId *string,
+       clusterID *string,
        uuid string,
        remainder string,
        w http.ResponseWriter,
index c62cea1168eb29c212ad5eefdd7a9d58dc609f8c..51f243e69e48d106bec6239c8cc8a66597dff60e 100644 (file)
@@ -19,7 +19,7 @@ import (
 func remoteContainerRequestCreate(
        h *genericFederatedRequestHandler,
        effectiveMethod string,
-       clusterId *string,
+       clusterID *string,
        uuid string,
        remainder string,
        w http.ResponseWriter,
@@ -42,7 +42,7 @@ func remoteContainerRequestCreate(
                return true
        }
 
-       if *clusterId == "" || *clusterId == h.handler.Cluster.ClusterID {
+       if *clusterID == "" || *clusterID == h.handler.Cluster.ClusterID {
                // Submitting container request to local cluster. No
                // need to set a runtime_token (rails api will create
                // one when the container runs) or do a remote cluster
@@ -117,7 +117,7 @@ func remoteContainerRequestCreate(
        req.ContentLength = int64(buf.Len())
        req.Header.Set("Content-Length", fmt.Sprintf("%v", buf.Len()))
 
-       resp, err := h.handler.remoteClusterRequest(*clusterId, req)
+       resp, err := h.handler.remoteClusterRequest(*clusterID, req)
        h.handler.proxy.ForwardResponse(w, resp, err)
        return true
 }
index 476fd97b05cd1c8a10ded9aaf43ef6b21744443c..fc2d96cc55fb5f4f0be7e46f55ee3f70445078a3 100644 (file)
@@ -20,7 +20,7 @@ import (
 type federatedRequestDelegate func(
        h *genericFederatedRequestHandler,
        effectiveMethod string,
-       clusterId *string,
+       clusterID *string,
        uuid string,
        remainder string,
        w http.ResponseWriter,
@@ -38,12 +38,12 @@ func (h *genericFederatedRequestHandler) remoteQueryUUIDs(w http.ResponseWriter,
        clusterID string, uuids []string) (rp []map[string]interface{}, kind string, err error) {
 
        found := make(map[string]bool)
-       prev_len_uuids := len(uuids) + 1
+       prevLenUuids := len(uuids) + 1
        // Loop while
        // (1) there are more uuids to query
        // (2) we're making progress - on each iteration the set of
        // uuids we are expecting for must shrink.
-       for len(uuids) > 0 && len(uuids) < prev_len_uuids {
+       for len(uuids) > 0 && len(uuids) < prevLenUuids {
                var remoteReq http.Request
                remoteReq.Header = req.Header
                remoteReq.Method = "POST"
@@ -103,7 +103,7 @@ func (h *genericFederatedRequestHandler) remoteQueryUUIDs(w http.ResponseWriter,
                                l = append(l, u)
                        }
                }
-               prev_len_uuids = len(uuids)
+               prevLenUuids = len(uuids)
                uuids = l
        }
 
@@ -111,7 +111,7 @@ func (h *genericFederatedRequestHandler) remoteQueryUUIDs(w http.ResponseWriter,
 }
 
 func (h *genericFederatedRequestHandler) handleMultiClusterQuery(w http.ResponseWriter,
-       req *http.Request, clusterId *string) bool {
+       req *http.Request, clusterID *string) bool {
 
        var filters [][]interface{}
        err := json.Unmarshal([]byte(req.Form.Get("filters")), &filters)
@@ -141,17 +141,17 @@ func (h *genericFederatedRequestHandler) handleMultiClusterQuery(w http.Response
                        if rhs, ok := filter[2].([]interface{}); ok {
                                for _, i := range rhs {
                                        if u, ok := i.(string); ok && len(u) == 27 {
-                                               *clusterId = u[0:5]
+                                               *clusterID = u[0:5]
                                                queryClusters[u[0:5]] = append(queryClusters[u[0:5]], u)
-                                               expectCount += 1
+                                               expectCount++
                                        }
                                }
                        }
                } else if op == "=" {
                        if u, ok := filter[2].(string); ok && len(u) == 27 {
-                               *clusterId = u[0:5]
+                               *clusterID = u[0:5]
                                queryClusters[u[0:5]] = append(queryClusters[u[0:5]], u)
-                               expectCount += 1
+                               expectCount++
                        }
                } else {
                        return false
@@ -256,10 +256,10 @@ func (h *genericFederatedRequestHandler) handleMultiClusterQuery(w http.Response
 
 func (h *genericFederatedRequestHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
        m := h.matcher.FindStringSubmatch(req.URL.Path)
-       clusterId := ""
+       clusterID := ""
 
        if len(m) > 0 && m[2] != "" {
-               clusterId = m[2]
+               clusterID = m[2]
        }
 
        // Get form parameters from URL and form body (if POST).
@@ -270,7 +270,7 @@ func (h *genericFederatedRequestHandler) ServeHTTP(w http.ResponseWriter, req *h
 
        // Check if the parameters have an explicit cluster_id
        if req.Form.Get("cluster_id") != "" {
-               clusterId = req.Form.Get("cluster_id")
+               clusterID = req.Form.Get("cluster_id")
        }
 
        // Handle the POST-as-GET special case (workaround for large
@@ -283,9 +283,9 @@ func (h *genericFederatedRequestHandler) ServeHTTP(w http.ResponseWriter, req *h
        }
 
        if effectiveMethod == "GET" &&
-               clusterId == "" &&
+               clusterID == "" &&
                req.Form.Get("filters") != "" &&
-               h.handleMultiClusterQuery(w, req, &clusterId) {
+               h.handleMultiClusterQuery(w, req, &clusterID) {
                return
        }
 
@@ -295,15 +295,15 @@ func (h *genericFederatedRequestHandler) ServeHTTP(w http.ResponseWriter, req *h
                uuid = m[1][1:]
        }
        for _, d := range h.delegates {
-               if d(h, effectiveMethod, &clusterId, uuid, m[3], w, req) {
+               if d(h, effectiveMethod, &clusterID, uuid, m[3], w, req) {
                        return
                }
        }
 
-       if clusterId == "" || clusterId == h.handler.Cluster.ClusterID {
+       if clusterID == "" || clusterID == h.handler.Cluster.ClusterID {
                h.next.ServeHTTP(w, req)
        } else {
-               resp, err := h.handler.remoteClusterRequest(clusterId, req)
+               resp, err := h.handler.remoteClusterRequest(clusterID, req)
                h.handler.proxy.ForwardResponse(w, resp, err)
        }
 }
index 562c8c1e7d7c66528a2ce0874eca034c9eb7b328..5c6a7b52f43f97842bf207859fcfed4f4d057cce 100644 (file)
@@ -69,14 +69,14 @@ type Client struct {
        defaultRequestID string
 }
 
-// The default http.Client used by a Client with Insecure==true and
-// Client==nil.
+// InsecureHTTPClient is the default http.Client used by a Client with
+// Insecure==true and Client==nil.
 var InsecureHTTPClient = &http.Client{
        Transport: &http.Transport{
                TLSClientConfig: &tls.Config{
                        InsecureSkipVerify: true}}}
 
-// The default http.Client used by a Client otherwise.
+// DefaultSecureClient is the default http.Client used by a Client otherwise.
 var DefaultSecureClient = &http.Client{}
 
 // NewClientFromConfig creates a new Client that uses the endpoints in
index e65baa3b3f48460329a49f95782b664b0bc150e0..d600322e6a8463a7a7a66577683aad6c697fa031 100644 (file)
@@ -2,7 +2,8 @@
 //
 // SPDX-License-Identifier: Apache-2.0
 
-/* Provides low-level Get/Put primitives for accessing Arvados Keep blocks. */
+// Package keepclient provides low-level Get/Put primitives for accessing
+// Arvados Keep blocks.
 package keepclient
 
 import (
@@ -25,7 +26,7 @@ import (
        "git.arvados.org/arvados.git/sdk/go/httpserver"
 )
 
-// A Keep "block" is 64MB.
+// BLOCKSIZE defines the length of a Keep "block", which is 64MB.
 const BLOCKSIZE = 64 * 1024 * 1024
 
 var (
@@ -82,8 +83,8 @@ var ErrNoSuchKeepServer = errors.New("No keep server matching the given UUID is
 // ErrIncompleteIndex is returned when the Index response does not end with a new empty line
 var ErrIncompleteIndex = errors.New("Got incomplete index")
 
-const X_Keep_Desired_Replicas = "X-Keep-Desired-Replicas"
-const X_Keep_Replicas_Stored = "X-Keep-Replicas-Stored"
+const XKeepDesiredReplicas = "X-Keep-Desired-Replicas"
+const XKeepReplicasStored = "X-Keep-Replicas-Stored"
 
 type HTTPClient interface {
        Do(*http.Request) (*http.Response, error)
@@ -139,7 +140,7 @@ func New(arv *arvadosclient.ArvadosClient) *KeepClient {
        }
 }
 
-// Put a block given the block hash, a reader, and the number of bytes
+// PutHR puts a block given the block hash, a reader, and the number of bytes
 // to read from the reader (which must be between 0 and BLOCKSIZE).
 //
 // Returns the locator for the written block, the number of replicas
@@ -216,7 +217,7 @@ func (kc *KeepClient) getOrHead(method string, locator string, header http.Heade
 
        var errs []string
 
-       tries_remaining := 1 + kc.Retries
+       triesRemaining := 1 + kc.Retries
 
        serversToTry := kc.getSortedRoots(locator)
 
@@ -225,8 +226,8 @@ func (kc *KeepClient) getOrHead(method string, locator string, header http.Heade
 
        var retryList []string
 
-       for tries_remaining > 0 {
-               tries_remaining -= 1
+       for triesRemaining > 0 {
+               triesRemaining -= 1
                retryList = nil
 
                for _, host := range serversToTry {
index f4e99bdbe3ef8c699d1bd7aadf97a861f5950b1d..6a31c98bc6596a5f946fc73ec0a8d22a66238b80 100644 (file)
@@ -79,7 +79,7 @@ func (this *KeepClient) uploadToKeepServer(host string, hash string, body io.Rea
        req.Header.Add("X-Request-Id", reqid)
        req.Header.Add("Authorization", "OAuth2 "+this.Arvados.ApiToken)
        req.Header.Add("Content-Type", "application/octet-stream")
-       req.Header.Add(X_Keep_Desired_Replicas, fmt.Sprint(this.Want_replicas))
+       req.Header.Add(XKeepDesiredReplicas, fmt.Sprint(this.Want_replicas))
        if len(this.StorageClasses) > 0 {
                req.Header.Add("X-Keep-Storage-Classes", strings.Join(this.StorageClasses, ", "))
        }
@@ -92,7 +92,7 @@ func (this *KeepClient) uploadToKeepServer(host string, hash string, body io.Rea
        }
 
        rep := 1
-       if xr := resp.Header.Get(X_Keep_Replicas_Stored); xr != "" {
+       if xr := resp.Header.Get(XKeepReplicasStored); xr != "" {
                fmt.Sscanf(xr, "%d", &rep)
        }
 
index 4e5014ef822d7551fc0e3db960b5c6d42f876f63..94e5c1d27516e4264b7a1c501fecc0de08c72bfe 100644 (file)
@@ -507,7 +507,7 @@ func (h *proxyHandler) Put(resp http.ResponseWriter, req *http.Request) {
        // Check if the client specified the number of replicas
        if req.Header.Get("X-Keep-Desired-Replicas") != "" {
                var r int
-               _, err := fmt.Sscanf(req.Header.Get(keepclient.X_Keep_Desired_Replicas), "%d", &r)
+               _, err := fmt.Sscanf(req.Header.Get(keepclient.XKeepDesiredReplicas), "%d", &r)
                if err == nil {
                        kc.Want_replicas = r
                }
@@ -527,7 +527,7 @@ func (h *proxyHandler) Put(resp http.ResponseWriter, req *http.Request) {
        }
 
        // Tell the client how many successful PUTs we accomplished
-       resp.Header().Set(keepclient.X_Keep_Replicas_Stored, fmt.Sprintf("%d", wroteReplicas))
+       resp.Header().Set(keepclient.XKeepReplicasStored, fmt.Sprintf("%d", wroteReplicas))
 
        switch err.(type) {
        case nil: