Skip to content

Commit

Permalink
Resolved lint issues
Browse files Browse the repository at this point in the history
Signed-off-by: Harold Wanyama <[email protected]>
  • Loading branch information
nickmango committed Oct 20, 2023
1 parent e627131 commit e0f4ab7
Show file tree
Hide file tree
Showing 4 changed files with 132 additions and 131 deletions.
30 changes: 15 additions & 15 deletions cla-backend-go/signatures/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -447,23 +447,23 @@ func (repo repository) GetSignature(ctx context.Context, signatureID string) (*m

// CreateOrUpdateSignature either creates or updates the signature record
func (repo repository) CreateOrUpdateSignature(ctx context.Context, signature *models.Signature) (*models.Signature, error) {
// f := logrus.Fields{
// "functionName": "v1.signatures.repository.CreateOrUpdateSignature",
// utils.XREQUESTID: ctx.Value(utils.XREQUESTID),
// }
f := logrus.Fields{
"functionName": "v1.signatures.repository.CreateOrUpdateSignature",
utils.XREQUESTID: ctx.Value(utils.XREQUESTID),
}

// // Check if we have an existing signature record
// existingSignature, sigErr := repo.GetSignature(ctx, signature.SignatureID)
// if sigErr != nil {
// log.WithFields(f).Warnf("error retrieving signature by ID: %s, error: %v", signature.SignatureID, sigErr)
// return nil, sigErr
// }
// Check if we have an existing signature record
existingSignature, sigErr := repo.GetSignature(ctx, signature.SignatureID)
if sigErr != nil {
log.WithFields(f).Warnf("error retrieving signature by ID: %s, error: %v", signature.SignatureID, sigErr)
return nil, sigErr
}

// // If we have an existing signature record, we need to update it
// if existingSignature != nil {
// log.WithFields(f).Debugf("updating existing signature record for signature ID: %s", signature.SignatureID)
// return repo.updateSignature(ctx, signature)
// }
// If we have an existing signature record, we need to update it
if existingSignature != nil {
log.WithFields(f).Debugf("updating existing signature record for signature ID: %s", signature.SignatureID)
return repo.updateSignature(ctx, signature)
}

return nil, nil
}
Expand Down
15 changes: 15 additions & 0 deletions cla-backend-go/v2/sign/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright The Linux Foundation and each contributor to LFX.
// SPDX-License-Identifier: MIT

package sign

const (
//Github is a constant for github
Github = "github"

// Unknown is a constant for unknown
Unknown = "Unknown"

// Gitlab is a constant for gitlab
Gitlab = "gitlab"
)
10 changes: 7 additions & 3 deletions cla-backend-go/v2/sign/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ func Configure(api *operations.EasyclaAPI, service Service) {
return sign.NewRequestIndividualSignatureBadRequest().WithPayload(errorResponse(reqId, errors.New(msg)))
}

if strings.ToLower(params.Input.ReturnURLType) == "github" || strings.ToLower(params.Input.ReturnURLType) == "gitlab" {
if strings.ToLower(params.Input.ReturnURLType) == "github" {
if strings.ToLower(params.Input.ReturnURLType) == Github || strings.ToLower(params.Input.ReturnURLType) == Gitlab {
if strings.ToLower(params.Input.ReturnURLType) == Github {
log.WithFields(f).Debug("fetching github emails")
emails, fetchErr := fetchGithubEmails(session, clientID)
if fetchErr != nil {
Expand Down Expand Up @@ -209,7 +209,11 @@ func fetchGithubEmails(session map[string]interface{}, clientID string) ([]map[s
return emails, err
}

defer resp.Body.Close()
defer func() {
if err = resp.Body.Close(); err != nil {
log.Warnf("problem closing the response body")
}
}()

if resp.StatusCode != 200 {
return emails, err
Expand Down
Loading

0 comments on commit e0f4ab7

Please sign in to comment.