[ARVADOS] updated: 2.1.0-154-g99187b7a8

Git user git at public.arvados.org
Thu Nov 26 22:17:19 UTC 2020


Summary of changes:
 sdk/go/keepclient/hashcheck.go       | 32 ++++++++++++++++----------------
 sdk/go/keepclient/keepclient_test.go | 10 +++++-----
 sdk/go/keepclient/support.go         | 26 +++++++++++++-------------
 3 files changed, 34 insertions(+), 34 deletions(-)

       via  99187b7a8e77008cf37efd2600e9fb49e1570943 (commit)
      from  8b1f33a3bdf2ce232ca300710649141fce5c71ff (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 99187b7a8e77008cf37efd2600e9fb49e1570943
Author: Ward Vandewege <ward at curii.com>
Date:   Thu Nov 26 17:17:10 2020 -0500

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

diff --git a/sdk/go/keepclient/hashcheck.go b/sdk/go/keepclient/hashcheck.go
index 9295c14cc..0966e072e 100644
--- a/sdk/go/keepclient/hashcheck.go
+++ b/sdk/go/keepclient/hashcheck.go
@@ -29,36 +29,36 @@ type HashCheckingReader struct {
 // Reads from the underlying reader, update the hashing function, and
 // pass the results through. Returns BadChecksum (instead of EOF) on
 // the last read if the checksum doesn't match.
-func (this HashCheckingReader) Read(p []byte) (n int, err error) {
-	n, err = this.Reader.Read(p)
+func (hcr HashCheckingReader) Read(p []byte) (n int, err error) {
+	n, err = hcr.Reader.Read(p)
 	if n > 0 {
-		this.Hash.Write(p[:n])
+		hcr.Hash.Write(p[:n])
 	}
 	if err == io.EOF {
-		sum := this.Hash.Sum(nil)
-		if fmt.Sprintf("%x", sum) != this.Check {
+		sum := hcr.Hash.Sum(nil)
+		if fmt.Sprintf("%x", sum) != hcr.Check {
 			err = BadChecksum
 		}
 	}
 	return n, err
 }
 
-// WriteTo writes the entire contents of this.Reader to dest. Returns
+// WriteTo writes the entire contents of hcr.Reader to dest. Returns
 // BadChecksum if writing is successful but the checksum doesn't
 // match.
-func (this HashCheckingReader) WriteTo(dest io.Writer) (written int64, err error) {
-	if writeto, ok := this.Reader.(io.WriterTo); ok {
-		written, err = writeto.WriteTo(io.MultiWriter(dest, this.Hash))
+func (hcr HashCheckingReader) WriteTo(dest io.Writer) (written int64, err error) {
+	if writeto, ok := hcr.Reader.(io.WriterTo); ok {
+		written, err = writeto.WriteTo(io.MultiWriter(dest, hcr.Hash))
 	} else {
-		written, err = io.Copy(io.MultiWriter(dest, this.Hash), this.Reader)
+		written, err = io.Copy(io.MultiWriter(dest, hcr.Hash), hcr.Reader)
 	}
 
 	if err != nil {
 		return written, err
 	}
 
-	sum := this.Hash.Sum(nil)
-	if fmt.Sprintf("%x", sum) != this.Check {
+	sum := hcr.Hash.Sum(nil)
+	if fmt.Sprintf("%x", sum) != hcr.Check {
 		return written, BadChecksum
 	}
 
@@ -68,10 +68,10 @@ func (this HashCheckingReader) WriteTo(dest io.Writer) (written int64, err error
 // Close reads all remaining data from the underlying Reader and
 // returns BadChecksum if the checksum doesn't match. It also closes
 // the underlying Reader if it implements io.ReadCloser.
-func (this HashCheckingReader) Close() (err error) {
-	_, err = io.Copy(this.Hash, this.Reader)
+func (hcr HashCheckingReader) Close() (err error) {
+	_, err = io.Copy(hcr.Hash, hcr.Reader)
 
-	if closer, ok := this.Reader.(io.Closer); ok {
+	if closer, ok := hcr.Reader.(io.Closer); ok {
 		closeErr := closer.Close()
 		if err == nil {
 			err = closeErr
@@ -80,7 +80,7 @@ func (this HashCheckingReader) Close() (err error) {
 	if err != nil {
 		return err
 	}
-	if fmt.Sprintf("%x", this.Hash.Sum(nil)) != this.Check {
+	if fmt.Sprintf("%x", hcr.Hash.Sum(nil)) != hcr.Check {
 		return BadChecksum
 	}
 	return nil
diff --git a/sdk/go/keepclient/keepclient_test.go b/sdk/go/keepclient/keepclient_test.go
index 59c412724..57a89b50a 100644
--- a/sdk/go/keepclient/keepclient_test.go
+++ b/sdk/go/keepclient/keepclient_test.go
@@ -97,7 +97,7 @@ func (s *ServerRequiredSuite) TestDefaultReplications(c *C) {
 type StubPutHandler struct {
 	c                  *C
 	expectPath         string
-	expectApiToken     string
+	expectAPIToken     string
 	expectBody         string
 	expectStorageClass string
 	handled            chan string
@@ -105,7 +105,7 @@ type StubPutHandler struct {
 
 func (sph StubPutHandler) ServeHTTP(resp http.ResponseWriter, req *http.Request) {
 	sph.c.Check(req.URL.Path, Equals, "/"+sph.expectPath)
-	sph.c.Check(req.Header.Get("Authorization"), Equals, fmt.Sprintf("OAuth2 %s", sph.expectApiToken))
+	sph.c.Check(req.Header.Get("Authorization"), Equals, fmt.Sprintf("OAuth2 %s", sph.expectAPIToken))
 	sph.c.Check(req.Header.Get("X-Keep-Storage-Classes"), Equals, sph.expectStorageClass)
 	body, err := ioutil.ReadAll(req.Body)
 	sph.c.Check(err, Equals, nil)
@@ -256,7 +256,7 @@ type KeepServer struct {
 func RunSomeFakeKeepServers(st http.Handler, n int) (ks []KeepServer) {
 	ks = make([]KeepServer, n)
 
-	for i := 0; i < n; i += 1 {
+	for i := 0; i < n; i++ {
 		ks[i] = RunFakeKeepServer(st)
 	}
 
@@ -464,14 +464,14 @@ func (s *StandaloneSuite) TestPutWithTooManyFail(c *C) {
 type StubGetHandler struct {
 	c              *C
 	expectPath     string
-	expectApiToken string
+	expectAPIToken string
 	httpStatus     int
 	body           []byte
 }
 
 func (sgh StubGetHandler) ServeHTTP(resp http.ResponseWriter, req *http.Request) {
 	sgh.c.Check(req.URL.Path, Equals, "/"+sgh.expectPath)
-	sgh.c.Check(req.Header.Get("Authorization"), Equals, fmt.Sprintf("OAuth2 %s", sgh.expectApiToken))
+	sgh.c.Check(req.Header.Get("Authorization"), Equals, fmt.Sprintf("OAuth2 %s", sgh.expectAPIToken))
 	resp.WriteHeader(sgh.httpStatus)
 	resp.Header().Set("Content-Length", fmt.Sprintf("%d", len(sgh.body)))
 	resp.Write(sgh.body)
diff --git a/sdk/go/keepclient/support.go b/sdk/go/keepclient/support.go
index 91117f2d3..3b1afe1e2 100644
--- a/sdk/go/keepclient/support.go
+++ b/sdk/go/keepclient/support.go
@@ -55,7 +55,7 @@ type uploadStatus struct {
 	response       string
 }
 
-func (this *KeepClient) uploadToKeepServer(host string, hash string, body io.Reader,
+func (kc *KeepClient) uploadToKeepServer(host string, hash string, body io.Reader,
 	uploadStatusChan chan<- uploadStatus, expectedLength int64, reqid string) {
 
 	var req *http.Request
@@ -77,15 +77,15 @@ 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("Authorization", "OAuth2 "+kc.Arvados.ApiToken)
 	req.Header.Add("Content-Type", "application/octet-stream")
-	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, ", "))
+	req.Header.Add(XKeepDesiredReplicas, fmt.Sprint(kc.Want_replicas))
+	if len(kc.StorageClasses) > 0 {
+		req.Header.Add("X-Keep-Storage-Classes", strings.Join(kc.StorageClasses, ", "))
 	}
 
 	var resp *http.Response
-	if resp, err = this.httpClient().Do(req); err != nil {
+	if resp, err = kc.httpClient().Do(req); err != nil {
 		DebugPrintf("DEBUG: [%s] Upload failed %v error: %v", reqid, url, err.Error())
 		uploadStatusChan <- uploadStatus{err, url, 0, 0, err.Error()}
 		return
@@ -116,15 +116,15 @@ func (this *KeepClient) uploadToKeepServer(host string, hash string, body io.Rea
 	}
 }
 
-func (this *KeepClient) putReplicas(
+func (kc *KeepClient) putReplicas(
 	hash string,
 	getReader func() io.Reader,
 	expectedLength int64) (locator string, replicas int, err error) {
 
-	reqid := this.getRequestID()
+	reqid := kc.getRequestID()
 
 	// Calculate the ordering for uploading to servers
-	sv := NewRootSorter(this.WritableLocalRoots(), hash).GetSortedRoots()
+	sv := NewRootSorter(kc.WritableLocalRoots(), hash).GetSortedRoots()
 
 	// The next server to try contacting
 	nextServer := 0
@@ -147,15 +147,15 @@ func (this *KeepClient) putReplicas(
 	}()
 
 	replicasDone := 0
-	replicasTodo := this.Want_replicas
+	replicasTodo := kc.Want_replicas
 
-	replicasPerThread := this.replicasPerService
+	replicasPerThread := kc.replicasPerService
 	if replicasPerThread < 1 {
 		// unlimited or unknown
 		replicasPerThread = replicasTodo
 	}
 
-	retriesRemaining := 1 + this.Retries
+	retriesRemaining := 1 + kc.Retries
 	var retryServers []string
 
 	lastError := make(map[string]string)
@@ -169,7 +169,7 @@ func (this *KeepClient) putReplicas(
 				// Start some upload requests
 				if nextServer < len(sv) {
 					DebugPrintf("DEBUG: [%s] Begin upload %s to %s", reqid, hash, sv[nextServer])
-					go this.uploadToKeepServer(sv[nextServer], hash, getReader(), uploadStatusChan, expectedLength, reqid)
+					go kc.uploadToKeepServer(sv[nextServer], hash, getReader(), uploadStatusChan, expectedLength, reqid)
 					nextServer++
 					active++
 				} else {

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list