[ARVADOS] updated: 1.3.0-3187-g02f779fee

Git user git at public.arvados.org
Sat Sep 19 14:51:39 UTC 2020


Summary of changes:
 lib/cloud/ec2/ec2.go                     |  3 +-
 lib/controller/federation/conn.go        |  3 +-
 lib/controller/localdb/login_oidc.go     | 56 +++++++++++++++-----------------
 lib/crunchrun/crunchrun_test.go          | 14 +++-----
 lib/dispatchcloud/worker/pool.go         |  3 +-
 services/crunch-dispatch-slurm/squeue.go | 15 ++++-----
 6 files changed, 42 insertions(+), 52 deletions(-)

       via  02f779feef0138420f8d7dc908eba040bc2dd904 (commit)
      from  641912ed2366dcd87c659fb73d8139e02cc6d05f (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 02f779feef0138420f8d7dc908eba040bc2dd904
Author: Ward Vandewege <ward at curii.com>
Date:   Sat Sep 19 10:51:25 2020 -0400

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

diff --git a/lib/cloud/ec2/ec2.go b/lib/cloud/ec2/ec2.go
index c329c1f88..29062c491 100644
--- a/lib/cloud/ec2/ec2.go
+++ b/lib/cloud/ec2/ec2.go
@@ -308,9 +308,8 @@ func (inst *ec2Instance) Destroy() error {
 func (inst *ec2Instance) Address() string {
 	if inst.instance.PrivateIpAddress != nil {
 		return *inst.instance.PrivateIpAddress
-	} else {
-		return ""
 	}
+	return ""
 }
 
 func (inst *ec2Instance) RemoteUser() string {
diff --git a/lib/controller/federation/conn.go b/lib/controller/federation/conn.go
index 361c9613d..61cac9bba 100644
--- a/lib/controller/federation/conn.go
+++ b/lib/controller/federation/conn.go
@@ -203,9 +203,8 @@ func (conn *Conn) Login(ctx context.Context, options arvados.LoginOptions) (arva
 		return arvados.LoginResponse{
 			RedirectLocation: target.String(),
 		}, nil
-	} else {
-		return conn.local.Login(ctx, options)
 	}
+	return conn.local.Login(ctx, options)
 }
 
 func (conn *Conn) Logout(ctx context.Context, options arvados.LogoutOptions) (arvados.LogoutResponse, error) {
diff --git a/lib/controller/localdb/login_oidc.go b/lib/controller/localdb/login_oidc.go
index 9274d75d7..e0b01f13e 100644
--- a/lib/controller/localdb/login_oidc.go
+++ b/lib/controller/localdb/login_oidc.go
@@ -106,34 +106,33 @@ func (ctrl *oidcLoginController) Login(ctx context.Context, opts arvados.LoginOp
 				// one Google account.
 				oauth2.SetAuthURLParam("prompt", "select_account")),
 		}, nil
-	} else {
-		// Callback after OIDC sign-in.
-		state := ctrl.parseOAuth2State(opts.State)
-		if !state.verify([]byte(ctrl.Cluster.SystemRootToken)) {
-			return loginError(errors.New("invalid OAuth2 state"))
-		}
-		oauth2Token, err := ctrl.oauth2conf.Exchange(ctx, opts.Code)
-		if err != nil {
-			return loginError(fmt.Errorf("error in OAuth2 exchange: %s", err))
-		}
-		rawIDToken, ok := oauth2Token.Extra("id_token").(string)
-		if !ok {
-			return loginError(errors.New("error in OAuth2 exchange: no ID token in OAuth2 token"))
-		}
-		idToken, err := ctrl.verifier.Verify(ctx, rawIDToken)
-		if err != nil {
-			return loginError(fmt.Errorf("error verifying ID token: %s", err))
-		}
-		authinfo, err := ctrl.getAuthInfo(ctx, oauth2Token, idToken)
-		if err != nil {
-			return loginError(err)
-		}
-		ctxRoot := auth.NewContext(ctx, &auth.Credentials{Tokens: []string{ctrl.Cluster.SystemRootToken}})
-		return ctrl.RailsProxy.UserSessionCreate(ctxRoot, rpc.UserSessionCreateOptions{
-			ReturnTo: state.Remote + "," + state.ReturnTo,
-			AuthInfo: *authinfo,
-		})
 	}
+	// Callback after OIDC sign-in.
+	state := ctrl.parseOAuth2State(opts.State)
+	if !state.verify([]byte(ctrl.Cluster.SystemRootToken)) {
+		return loginError(errors.New("invalid OAuth2 state"))
+	}
+	oauth2Token, err := ctrl.oauth2conf.Exchange(ctx, opts.Code)
+	if err != nil {
+		return loginError(fmt.Errorf("error in OAuth2 exchange: %s", err))
+	}
+	rawIDToken, ok := oauth2Token.Extra("id_token").(string)
+	if !ok {
+		return loginError(errors.New("error in OAuth2 exchange: no ID token in OAuth2 token"))
+	}
+	idToken, err := ctrl.verifier.Verify(ctx, rawIDToken)
+	if err != nil {
+		return loginError(fmt.Errorf("error verifying ID token: %s", err))
+	}
+	authinfo, err := ctrl.getAuthInfo(ctx, oauth2Token, idToken)
+	if err != nil {
+		return loginError(err)
+	}
+	ctxRoot := auth.NewContext(ctx, &auth.Credentials{Tokens: []string{ctrl.Cluster.SystemRootToken}})
+	return ctrl.RailsProxy.UserSessionCreate(ctxRoot, rpc.UserSessionCreateOptions{
+		ReturnTo: state.Remote + "," + state.ReturnTo,
+		AuthInfo: *authinfo,
+	})
 }
 
 func (ctrl *oidcLoginController) UserAuthenticate(ctx context.Context, opts arvados.UserAuthenticateOptions) (arvados.APIClientAuthorization, error) {
@@ -190,9 +189,8 @@ func (ctrl *oidcLoginController) getAuthInfo(ctx context.Context, token *oauth2.
 			// only the "fix config" advice to the user.
 			ctxlog.FromContext(ctx).WithError(err).WithField("email", ret.Email).Error("People API is not enabled")
 			return nil, errors.New("configuration error: Login.GoogleAlternateEmailAddresses is true, but Google People API is not enabled")
-		} else {
-			return nil, fmt.Errorf("error getting profile info from People API: %s", err)
 		}
+		return nil, fmt.Errorf("error getting profile info from People API: %s", err)
 	}
 
 	// The given/family names returned by the People API and
diff --git a/lib/crunchrun/crunchrun_test.go b/lib/crunchrun/crunchrun_test.go
index e8c7660d1..55cc6ee56 100644
--- a/lib/crunchrun/crunchrun_test.go
+++ b/lib/crunchrun/crunchrun_test.go
@@ -157,9 +157,8 @@ func (t *TestDockerClient) ContainerStart(ctx context.Context, container string,
 	if container == "abcde" {
 		// t.fn gets executed in ContainerWait
 		return nil
-	} else {
-		return errors.New("Invalid container id")
 	}
+	return errors.New("Invalid container id")
 }
 
 func (t *TestDockerClient) ContainerRemove(ctx context.Context, container string, options dockertypes.ContainerRemoveOptions) error {
@@ -196,9 +195,8 @@ func (t *TestDockerClient) ImageInspectWithRaw(ctx context.Context, image string
 
 	if t.imageLoaded == image {
 		return dockertypes.ImageInspect{}, nil, nil
-	} else {
-		return dockertypes.ImageInspect{}, nil, errors.New("")
 	}
+	return dockertypes.ImageInspect{}, nil, errors.New("")
 }
 
 func (t *TestDockerClient) ImageLoad(ctx context.Context, input io.Reader, quiet bool) (dockertypes.ImageLoadResponse, error) {
@@ -208,10 +206,9 @@ func (t *TestDockerClient) ImageLoad(ctx context.Context, input io.Reader, quiet
 	_, err := io.Copy(ioutil.Discard, input)
 	if err != nil {
 		return dockertypes.ImageLoadResponse{}, err
-	} else {
-		t.imageLoaded = hwImageId
-		return dockertypes.ImageLoadResponse{Body: ioutil.NopCloser(input)}, nil
 	}
+	t.imageLoaded = hwImageId
+	return dockertypes.ImageLoadResponse{Body: ioutil.NopCloser(input)}, nil
 }
 
 func (*TestDockerClient) ImageRemove(ctx context.Context, image string, options dockertypes.ImageRemoveOptions) ([]dockertypes.ImageDeleteResponseItem, error) {
@@ -260,9 +257,8 @@ func (client *ArvTestClient) Call(method, resourceType, uuid, action string, par
 	case method == "GET" && resourceType == "containers" && action == "secret_mounts":
 		if client.secretMounts != nil {
 			return json.Unmarshal(client.secretMounts, output)
-		} else {
-			return json.Unmarshal([]byte(`{"secret_mounts":{}}`), output)
 		}
+		return json.Unmarshal([]byte(`{"secret_mounts":{}}`), output)
 	default:
 		return fmt.Errorf("Not found")
 	}
diff --git a/lib/dispatchcloud/worker/pool.go b/lib/dispatchcloud/worker/pool.go
index 72d5ca56e..a25ed6015 100644
--- a/lib/dispatchcloud/worker/pool.go
+++ b/lib/dispatchcloud/worker/pool.go
@@ -86,9 +86,8 @@ const (
 func duration(conf arvados.Duration, def time.Duration) time.Duration {
 	if conf > 0 {
 		return time.Duration(conf)
-	} else {
-		return def
 	}
+	return def
 }
 
 // NewPool creates a Pool of workers backed by instanceSet.
diff --git a/services/crunch-dispatch-slurm/squeue.go b/services/crunch-dispatch-slurm/squeue.go
index 5aee7e087..eae21e62b 100644
--- a/services/crunch-dispatch-slurm/squeue.go
+++ b/services/crunch-dispatch-slurm/squeue.go
@@ -23,8 +23,8 @@ type slurmJob struct {
 	hitNiceLimit bool
 }
 
-// Squeue implements asynchronous polling monitor of the SLURM queue using the
-// command 'squeue'.
+// SqueueChecker implements asynchronous polling monitor of the SLURM queue
+// using the command 'squeue'.
 type SqueueChecker struct {
 	Logger         logger
 	Period         time.Duration
@@ -102,13 +102,12 @@ func (sqc *SqueueChecker) reniceAll() {
 	sort.Slice(jobs, func(i, j int) bool {
 		if jobs[i].wantPriority != jobs[j].wantPriority {
 			return jobs[i].wantPriority > jobs[j].wantPriority
-		} else {
-			// break ties with container uuid --
-			// otherwise, the ordering would change from
-			// one interval to the next, and we'd do many
-			// pointless slurm queue rearrangements.
-			return jobs[i].uuid > jobs[j].uuid
 		}
+		// break ties with container uuid --
+		// otherwise, the ordering would change from
+		// one interval to the next, and we'd do many
+		// pointless slurm queue rearrangements.
+		return jobs[i].uuid > jobs[j].uuid
 	})
 	renice := wantNice(jobs, sqc.PrioritySpread)
 	for i, job := range jobs {

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list