Skip to content

Commit

Permalink
Removed Duplicate CCLA Get Signature API Call (#2862)
Browse files Browse the repository at this point in the history
- Only load gerrit user list on approval list removals
- Updated logging/error handling
- Load both ICLA and CCLA gerrit users using a go routine (concurrently)
- Resolved lint errors
- Updated signature query by using the proper index

Signed-off-by: David Deal <[email protected]>
  • Loading branch information
dealako authored Apr 9, 2021
1 parent 96f8c50 commit 41e08cd
Show file tree
Hide file tree
Showing 7 changed files with 179 additions and 167 deletions.
6 changes: 2 additions & 4 deletions cla-backend-go/gerrits/lf_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
// constants
const (
DefaultHTTPTimeout = 10 * time.Second
LongHTTPTimeout = 45 * time.Second
)

// LFGroup contains access information of lf LDAP group
Expand Down Expand Up @@ -186,7 +187,7 @@ func (lfg *LFGroup) GetUsersOfGroup(ctx context.Context, authUser *auth.User, cl
req.Header.Add("Content-Type", "application/json")
req.Header.Add("Authorization", "Bearer "+accessToken)
client := http.Client{
Timeout: DefaultHTTPTimeout,
Timeout: LongHTTPTimeout,
}

// Invoke the request
Expand All @@ -209,8 +210,6 @@ func (lfg *LFGroup) GetUsersOfGroup(ctx context.Context, authUser *auth.User, cl
log.WithFields(f).Debugf("successfully fetched members from group: %s", groupName)

var result v2Models.GerritGroupResponse
//err = json.NewDecoder(resp.Body).Decode(&result)

body, err := ioutil.ReadAll(resp.Body)
if err != nil {
log.WithFields(f).WithError(err).Warnf("problem reading response for url: %s", url)
Expand All @@ -223,7 +222,6 @@ func (lfg *LFGroup) GetUsersOfGroup(ctx context.Context, authUser *auth.User, cl
log.WithFields(f).WithError(err).Warnf("problem unmarshalling response for url: %s", url)
return nil, err
}
log.WithFields(f).Debugf("response body: %+v", result)

return &result, nil
}
Expand Down
6 changes: 3 additions & 3 deletions cla-backend-go/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ replace github.com/awslabs/aws-lambda-go-api-proxy => github.com/LF-Engineering/

require (
github.com/LF-Engineering/aws-lambda-go-api-proxy v0.3.2
github.com/LF-Engineering/lfx-kit v0.1.22
github.com/LF-Engineering/lfx-models v0.6.34
github.com/LF-Engineering/lfx-kit v0.1.24
github.com/LF-Engineering/lfx-models v0.6.42
github.com/aws/aws-lambda-go v1.22.0
github.com/aws/aws-sdk-go v1.36.27
github.com/aymerick/raymond v2.0.2+incompatible
Expand All @@ -28,7 +28,7 @@ require (
github.com/go-openapi/swag v0.19.9
github.com/go-openapi/validate v0.19.10
github.com/go-resty/resty/v2 v2.3.0
github.com/gofrs/uuid v3.2.0+incompatible
github.com/gofrs/uuid v4.0.0+incompatible
github.com/golang/mock v1.4.4
github.com/golang/protobuf v1.4.3 // indirect
github.com/google/go-github/v33 v33.0.0
Expand Down
6 changes: 6 additions & 0 deletions cla-backend-go/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,12 @@ github.com/LF-Engineering/aws-lambda-go-api-proxy v0.3.2 h1:ZLAgTj9+H3RTmjbRpUam
github.com/LF-Engineering/aws-lambda-go-api-proxy v0.3.2/go.mod h1:LQj48zwkRwdjVmDCqtPlviW/7IFaSKzz2gDhxRwVrA4=
github.com/LF-Engineering/lfx-kit v0.1.22 h1:4tE1xTvu5CRWIokOo1waOfuB6vgaCpov5glhkdVzbAs=
github.com/LF-Engineering/lfx-kit v0.1.22/go.mod h1:B+pko2SqvGNSG9hWDC35JNZ38nTPt+r5KB6k75xM5vY=
github.com/LF-Engineering/lfx-kit v0.1.24 h1:2lfmBMWWfOwU2XEOSP7keS/CqR5mj30YmJPv6fUiOvM=
github.com/LF-Engineering/lfx-kit v0.1.24/go.mod h1:B+pko2SqvGNSG9hWDC35JNZ38nTPt+r5KB6k75xM5vY=
github.com/LF-Engineering/lfx-models v0.6.34 h1:K8al2aTq8nDm3qNmsTNAhZ1uDzfew/UymwbcW9gbDDs=
github.com/LF-Engineering/lfx-models v0.6.34/go.mod h1:AaV7psgE2IPXhaLXYXoFviobYoh09XJ2P/ALOU11OuE=
github.com/LF-Engineering/lfx-models v0.6.42 h1:PfvP/hmcV+OHftNrzclzvwGUv864xyNcp0Kz2HUA5C0=
github.com/LF-Engineering/lfx-models v0.6.42/go.mod h1:AaV7psgE2IPXhaLXYXoFviobYoh09XJ2P/ALOU11OuE=
github.com/Masterminds/semver v1.5.0 h1:H65muMkzWKEuNDnfl9d70GUjFniHKHRbFPGBuZ3QEww=
github.com/Masterminds/semver v1.5.0/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y=
github.com/Masterminds/vcs v1.13.1 h1:NL3G1X7/7xduQtA2sJLpVpfHTNBALVNSjob6KEjPXNQ=
Expand Down Expand Up @@ -265,6 +269,8 @@ github.com/gobuffalo/syncx v0.0.0-20190224160051-33c29581e754 h1:tpom+2CJmpzAWj5
github.com/gobuffalo/syncx v0.0.0-20190224160051-33c29581e754/go.mod h1:HhnNqWY95UYwwW3uSASeV7vtgYkT2t16hJgV3AEPUpw=
github.com/gofrs/uuid v3.2.0+incompatible h1:y12jRkkFxsd7GpqdSZ+/KCs/fJbqpEXSGd4+jfEaewE=
github.com/gofrs/uuid v3.2.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
github.com/gofrs/uuid v4.0.0+incompatible h1:1SD/1F5pU8p29ybwgQSwpQk+mwdRrXCYuPhW6m+TnJw=
github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
github.com/gogo/protobuf v1.2.1 h1:/s5zKNz0uPFCZ5hddgPdo2TK2TVrUNMn0OOX8/aZMTE=
github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
Expand Down
9 changes: 9 additions & 0 deletions cla-backend-go/signatures/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

package signatures

import v2Models "github.com/communitybridge/easycla/cla-backend-go/gen/v2/models"

// SignatureCompanyID is a simple data model to hold the signature ID and come company details for CCLA's
type SignatureCompanyID struct {
SignatureID string
Expand Down Expand Up @@ -33,3 +35,10 @@ type ApprovalList struct {
GHUsernames []string
GerritICLAECLAs []string
}

// GerritUserResponse is a data structure to hold the gerrit user query response
type GerritUserResponse struct {
gerritGroupResponse *v2Models.GerritGroupResponse
queryType string
Error error
}
Loading

0 comments on commit 41e08cd

Please sign in to comment.