[ARVADOS] updated: 1.3.0-3255-g08bf214e0

Git user git at public.arvados.org
Sat Oct 3 01:10:34 UTC 2020


Summary of changes:
 sdk/go/manifest/manifest.go     | 68 ++++++++++++++++++++---------------------
 services/keepproxy/keepproxy.go | 44 +++++++++++++-------------
 2 files changed, 56 insertions(+), 56 deletions(-)

       via  08bf214e0170019e78c4c5496944ede12bf14978 (commit)
      from  2abdbcf641c2c6cb14764a3ed0d83849a4c7736a (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit 08bf214e0170019e78c4c5496944ede12bf14978
Author: Ward Vandewege <ward at curii.com>
Date:   Fri Oct 2 21:10:19 2020 -0400

    Fix some more golint warnings.
    
    No issue #
    
    Arvados-DCO-1.1-Signed-off-by: Ward Vandewege <ward at curii.com>

diff --git a/sdk/go/manifest/manifest.go b/sdk/go/manifest/manifest.go
index ec9ae6ece..7a705eb8c 100644
--- a/sdk/go/manifest/manifest.go
+++ b/sdk/go/manifest/manifest.go
@@ -48,7 +48,7 @@ type FileStreamSegment struct {
 	Name   string
 }
 
-// Represents a single line from a manifest.
+// ManifestStream represents a single line from a manifest.
 type ManifestStream struct {
 	StreamName         string
 	Blocks             []string
@@ -152,32 +152,32 @@ func (s *ManifestStream) FileSegmentIterByName(filepath string) <-chan *FileSegm
 	return ch
 }
 
-func firstBlock(offsets []uint64, range_start uint64) int {
-	// range_start/block_start is the inclusive lower bound
-	// range_end/block_end is the exclusive upper bound
+func firstBlock(offsets []uint64, rangeStart uint64) int {
+	// rangeStart/blockStart is the inclusive lower bound
+	// rangeEnd/blockEnd is the exclusive upper bound
 
 	hi := len(offsets) - 1
 	var lo int
 	i := ((hi + lo) / 2)
-	block_start := offsets[i]
-	block_end := offsets[i+1]
+	blockStart := offsets[i]
+	blockEnd := offsets[i+1]
 
 	// perform a binary search for the first block
-	// assumes that all of the blocks are contiguous, so range_start is guaranteed
+	// assumes that all of the blocks are contiguous, so rangeStart is guaranteed
 	// to either fall into the range of a block or be outside the block range entirely
-	for !(range_start >= block_start && range_start < block_end) {
+	for !(rangeStart >= blockStart && rangeStart < blockEnd) {
 		if lo == i {
 			// must be out of range, fail
 			return -1
 		}
-		if range_start > block_start {
+		if rangeStart > blockStart {
 			lo = i
 		} else {
 			hi = i
 		}
 		i = ((hi + lo) / 2)
-		block_start = offsets[i]
-		block_end = offsets[i+1]
+		blockStart = offsets[i]
+		blockEnd = offsets[i+1]
 	}
 	return i
 }
@@ -357,7 +357,7 @@ func (stream segmentedStream) normalizedText(name string) string {
 	}
 	sort.Strings(sortedfiles)
 
-	stream_tokens := []string{EscapeName(name)}
+	streamTokens := []string{EscapeName(name)}
 
 	blocks := make(map[blockdigest.BlockDigest]int64)
 	var streamoffset int64
@@ -367,50 +367,50 @@ func (stream segmentedStream) normalizedText(name string) string {
 		for _, segment := range stream[streamfile] {
 			b, _ := ParseBlockLocator(segment.Locator)
 			if _, ok := blocks[b.Digest]; !ok {
-				stream_tokens = append(stream_tokens, segment.Locator)
+				streamTokens = append(streamTokens, segment.Locator)
 				blocks[b.Digest] = streamoffset
 				streamoffset += int64(b.Size)
 			}
 		}
 	}
 
-	if len(stream_tokens) == 1 {
-		stream_tokens = append(stream_tokens, "d41d8cd98f00b204e9800998ecf8427e+0")
+	if len(streamTokens) == 1 {
+		streamTokens = append(streamTokens, "d41d8cd98f00b204e9800998ecf8427e+0")
 	}
 
 	for _, streamfile := range sortedfiles {
 		// Add in file segments
-		span_start := int64(-1)
-		span_end := int64(0)
+		spanStart := int64(-1)
+		spanEnd := int64(0)
 		fout := EscapeName(streamfile)
 		for _, segment := range stream[streamfile] {
 			// Collapse adjacent segments
 			b, _ := ParseBlockLocator(segment.Locator)
 			streamoffset = blocks[b.Digest] + int64(segment.Offset)
-			if span_start == -1 {
-				span_start = streamoffset
-				span_end = streamoffset + int64(segment.Len)
+			if spanStart == -1 {
+				spanStart = streamoffset
+				spanEnd = streamoffset + int64(segment.Len)
 			} else {
-				if streamoffset == span_end {
-					span_end += int64(segment.Len)
+				if streamoffset == spanEnd {
+					spanEnd += int64(segment.Len)
 				} else {
-					stream_tokens = append(stream_tokens, fmt.Sprintf("%d:%d:%s", span_start, span_end-span_start, fout))
-					span_start = streamoffset
-					span_end = streamoffset + int64(segment.Len)
+					streamTokens = append(streamTokens, fmt.Sprintf("%d:%d:%s", spanStart, spanEnd-spanStart, fout))
+					spanStart = streamoffset
+					spanEnd = streamoffset + int64(segment.Len)
 				}
 			}
 		}
 
-		if span_start != -1 {
-			stream_tokens = append(stream_tokens, fmt.Sprintf("%d:%d:%s", span_start, span_end-span_start, fout))
+		if spanStart != -1 {
+			streamTokens = append(streamTokens, fmt.Sprintf("%d:%d:%s", spanStart, spanEnd-spanStart, fout))
 		}
 
 		if len(stream[streamfile]) == 0 {
-			stream_tokens = append(stream_tokens, fmt.Sprintf("0:0:%s", fout))
+			streamTokens = append(streamTokens, fmt.Sprintf("0:0:%s", fout))
 		}
 	}
 
-	return strings.Join(stream_tokens, " ") + "\n"
+	return strings.Join(streamTokens, " ") + "\n"
 }
 
 func (m segmentedManifest) manifestTextForPath(srcpath, relocate string) string {
@@ -429,12 +429,12 @@ func (m segmentedManifest) manifestTextForPath(srcpath, relocate string) string
 		filesegs, okfile := stream[filename]
 		if okfile {
 			newstream := make(segmentedStream)
-			relocate_stream, relocate_filename := splitPath(relocate)
-			if relocate_filename == "" {
-				relocate_filename = filename
+			relocateStream, relocateFilename := splitPath(relocate)
+			if relocateFilename == "" {
+				relocateFilename = filename
 			}
-			newstream[relocate_filename] = filesegs
-			return newstream.normalizedText(relocate_stream)
+			newstream[relocateFilename] = filesegs
+			return newstream.normalizedText(relocateStream)
 		}
 	}
 
diff --git a/services/keepproxy/keepproxy.go b/services/keepproxy/keepproxy.go
index 0191e5ba4..4e5014ef8 100644
--- a/services/keepproxy/keepproxy.go
+++ b/services/keepproxy/keepproxy.go
@@ -167,7 +167,7 @@ func run(logger log.FieldLogger, cluster *arvados.Cluster) error {
 	return http.Serve(listener, httpserver.AddRequestIDs(httpserver.LogRequests(router)))
 }
 
-type ApiTokenCache struct {
+type APITokenCache struct {
 	tokens     map[string]int64
 	lock       sync.Mutex
 	expireTime int64
@@ -175,7 +175,7 @@ type ApiTokenCache struct {
 
 // 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) {
+func (this *APITokenCache) RememberToken(token string) {
 	this.lock.Lock()
 	defer this.lock.Unlock()
 
@@ -186,7 +186,7 @@ func (this *ApiTokenCache) RememberToken(token string) {
 }
 
 // Check if the cached token is known and still believed to be valid.
-func (this *ApiTokenCache) RecallToken(token string) bool {
+func (this *APITokenCache) RecallToken(token string) bool {
 	this.lock.Lock()
 	defer this.lock.Unlock()
 
@@ -211,7 +211,7 @@ func GetRemoteAddress(req *http.Request) string {
 	return req.RemoteAddr
 }
 
-func CheckAuthorizationHeader(kc *keepclient.KeepClient, cache *ApiTokenCache, req *http.Request) (pass bool, tok string) {
+func CheckAuthorizationHeader(kc *keepclient.KeepClient, cache *APITokenCache, req *http.Request) (pass bool, tok string) {
 	parts := strings.SplitN(req.Header.Get("Authorization"), " ", 2)
 	if len(parts) < 2 || !(parts[0] == "OAuth2" || parts[0] == "Bearer") || len(parts[1]) == 0 {
 		return false, ""
@@ -265,7 +265,7 @@ var defaultTransport = *(http.DefaultTransport.(*http.Transport))
 type proxyHandler struct {
 	http.Handler
 	*keepclient.KeepClient
-	*ApiTokenCache
+	*APITokenCache
 	timeout   time.Duration
 	transport *http.Transport
 }
@@ -289,7 +289,7 @@ func MakeRESTRouter(kc *keepclient.KeepClient, timeout time.Duration, mgmtToken
 		KeepClient: kc,
 		timeout:    timeout,
 		transport:  &transport,
-		ApiTokenCache: &ApiTokenCache{
+		APITokenCache: &APITokenCache{
 			tokens:     make(map[string]int64),
 			expireTime: 300,
 		},
@@ -349,9 +349,9 @@ func (h *proxyHandler) Options(resp http.ResponseWriter, req *http.Request) {
 	SetCorsHeaders(resp)
 }
 
-var BadAuthorizationHeader = errors.New("Missing or invalid Authorization header")
-var ContentLengthMismatch = errors.New("Actual length != expected content length")
-var MethodNotSupported = errors.New("Method not supported")
+var errBadAuthorizationHeader = errors.New("Missing or invalid Authorization header")
+var errContentLengthMismatch = errors.New("Actual length != expected content length")
+var errMethodNotSupported = errors.New("Method not supported")
 
 var removeHint, _ = regexp.Compile("\\+K@[a-z0-9]{5}(\\+|$)")
 
@@ -379,8 +379,8 @@ func (h *proxyHandler) Get(resp http.ResponseWriter, req *http.Request) {
 
 	var pass bool
 	var tok string
-	if pass, tok = CheckAuthorizationHeader(kc, h.ApiTokenCache, req); !pass {
-		status, err = http.StatusForbidden, BadAuthorizationHeader
+	if pass, tok = CheckAuthorizationHeader(kc, h.APITokenCache, req); !pass {
+		status, err = http.StatusForbidden, errBadAuthorizationHeader
 		return
 	}
 
@@ -402,7 +402,7 @@ func (h *proxyHandler) Get(resp http.ResponseWriter, req *http.Request) {
 			defer reader.Close()
 		}
 	default:
-		status, err = http.StatusNotImplemented, MethodNotSupported
+		status, err = http.StatusNotImplemented, errMethodNotSupported
 		return
 	}
 
@@ -420,7 +420,7 @@ func (h *proxyHandler) Get(resp http.ResponseWriter, req *http.Request) {
 		case "GET":
 			responseLength, err = io.Copy(resp, reader)
 			if err == nil && expectLength > -1 && responseLength != expectLength {
-				err = ContentLengthMismatch
+				err = errContentLengthMismatch
 			}
 		}
 	case keepclient.Error:
@@ -436,8 +436,8 @@ func (h *proxyHandler) Get(resp http.ResponseWriter, req *http.Request) {
 	}
 }
 
-var LengthRequiredError = errors.New(http.StatusText(http.StatusLengthRequired))
-var LengthMismatchError = errors.New("Locator size hint does not match Content-Length header")
+var errLengthRequired = errors.New(http.StatusText(http.StatusLengthRequired))
+var errLengthMismatch = errors.New("Locator size hint does not match Content-Length header")
 
 func (h *proxyHandler) Put(resp http.ResponseWriter, req *http.Request) {
 	if err := h.checkLoop(resp, req); err != nil {
@@ -474,7 +474,7 @@ func (h *proxyHandler) Put(resp http.ResponseWriter, req *http.Request) {
 
 	_, err = fmt.Sscanf(req.Header.Get("Content-Length"), "%d", &expectLength)
 	if err != nil || expectLength < 0 {
-		err = LengthRequiredError
+		err = errLengthRequired
 		status = http.StatusLengthRequired
 		return
 	}
@@ -485,7 +485,7 @@ func (h *proxyHandler) Put(resp http.ResponseWriter, req *http.Request) {
 			status = http.StatusBadRequest
 			return
 		} else if loc.Size > 0 && int64(loc.Size) != expectLength {
-			err = LengthMismatchError
+			err = errLengthMismatch
 			status = http.StatusBadRequest
 			return
 		}
@@ -493,8 +493,8 @@ func (h *proxyHandler) Put(resp http.ResponseWriter, req *http.Request) {
 
 	var pass bool
 	var tok string
-	if pass, tok = CheckAuthorizationHeader(kc, h.ApiTokenCache, req); !pass {
-		err = BadAuthorizationHeader
+	if pass, tok = CheckAuthorizationHeader(kc, h.APITokenCache, req); !pass {
+		err = errBadAuthorizationHeader
 		status = http.StatusForbidden
 		return
 	}
@@ -575,9 +575,9 @@ func (h *proxyHandler) Index(resp http.ResponseWriter, req *http.Request) {
 	}()
 
 	kc := h.makeKeepClient(req)
-	ok, token := CheckAuthorizationHeader(kc, h.ApiTokenCache, req)
+	ok, token := CheckAuthorizationHeader(kc, h.APITokenCache, req)
 	if !ok {
-		status, err = http.StatusForbidden, BadAuthorizationHeader
+		status, err = http.StatusForbidden, errBadAuthorizationHeader
 		return
 	}
 
@@ -588,7 +588,7 @@ func (h *proxyHandler) Index(resp http.ResponseWriter, req *http.Request) {
 
 	// Only GET method is supported
 	if req.Method != "GET" {
-		status, err = http.StatusNotImplemented, MethodNotSupported
+		status, err = http.StatusNotImplemented, errMethodNotSupported
 		return
 	}
 

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list