Fix more golint warnings.
authorWard Vandewege <ward@curii.com>
Sun, 1 Nov 2020 22:27:04 +0000 (17:27 -0500)
committerWard Vandewege <ward@curii.com>
Sun, 1 Nov 2020 22:27:04 +0000 (17:27 -0500)
No issue #

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

lib/crunchrun/background.go
sdk/go/arvados/link.go
services/keepproxy/keepproxy.go

index 8cdba72c10d3c5902225456de9389bcc70b6dbca..da536107947187e3e88f1b59800a8d217666ca00 100644 (file)
@@ -162,7 +162,7 @@ func kill(uuid string, signal syscall.Signal, stdout, stderr io.Writer) error {
        return nil
 }
 
-// List UUIDs of active crunch-run processes.
+// ListProcesses lists UUIDs of active crunch-run processes.
 func ListProcesses(stdout, stderr io.Writer) int {
        // filepath.Walk does not follow symlinks, so we must walk
        // lockdir+"/." in case lockdir itself is a symlink.
index fdddfc537d8ee3b1dca86853232dc7017851969b..f7d1f35a3c322953c702437ca5caecd40687bddd 100644 (file)
@@ -17,7 +17,7 @@ type Link struct {
        Properties map[string]interface{} `json:"properties"`
 }
 
-// UserList is an arvados#userList resource.
+// LinkList is an arvados#linkList resource.
 type LinkList struct {
        Items          []Link `json:"items"`
        ItemsAvailable int    `json:"items_available"`
index 94e5c1d27516e4264b7a1c501fecc0de08c72bfe..538a0612275ec029e448b810f45bcdd08fee74bb 100644 (file)
@@ -173,37 +173,42 @@ type APITokenCache struct {
        expireTime int64
 }
 
-// Cache the token and set an expire time.  If we already have an expire time
-// on the token, it is not updated.
-func (this *APITokenCache) RememberToken(token string) {
-       this.lock.Lock()
-       defer this.lock.Unlock()
+// RememberToken caches the token and set an expire time.  If we already have
+// an expire time on the token, it is not updated.
+func (cache *APITokenCache) RememberToken(token string) {
+       cache.lock.Lock()
+       defer cache.lock.Unlock()
 
        now := time.Now().Unix()
-       if this.tokens[token] == 0 {
-               this.tokens[token] = now + this.expireTime
+       if cache.tokens[token] == 0 {
+               cache.tokens[token] = now + cache.expireTime
        }
 }
 
-// Check if the cached token is known and still believed to be valid.
-func (this *APITokenCache) RecallToken(token string) bool {
-       this.lock.Lock()
-       defer this.lock.Unlock()
+// RecallToken checks if the cached token is known and still believed to be
+// valid.
+func (cache *APITokenCache) RecallToken(token string) bool {
+       cache.lock.Lock()
+       defer cache.lock.Unlock()
 
        now := time.Now().Unix()
-       if this.tokens[token] == 0 {
+       if cache.tokens[token] == 0 {
                // Unknown token
                return false
-       } else if now < this.tokens[token] {
+       } else if now < cache.tokens[token] {
                // Token is known and still valid
                return true
        } else {
                // Token is expired
-               this.tokens[token] = 0
+               cache.tokens[token] = 0
                return false
        }
 }
 
+// GetRemoteAddress returns a string with the remote address for the request.
+// If the X-Forwarded-For header is set and has a non-zero length, it returns a
+// string made from a comma separated list of all the remote addresses,
+// starting with the one(s) from the X-Forwarded-For header.
 func GetRemoteAddress(req *http.Request) string {
        if xff := req.Header.Get("X-Forwarded-For"); xff != "" {
                return xff + "," + req.RemoteAddr