From fde2528ddc0e3ab944d620535c4c407cb33ac009 Mon Sep 17 00:00:00 2001 From: Harold Wanyama Date: Thu, 12 Oct 2023 14:56:21 +0300 Subject: [PATCH] Lint Issues - Fixed lint issues for golang docusign integration Signed-off-by: Harold Wanyama --- cla-backend-go/utils/constants.go | 5 +++++ cla-backend-go/v2/sign/docusign.go | 6 +++++- cla-backend-go/v2/sign/handlers.go | 2 +- cla-backend-go/v2/sign/service.go | 7 ------- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/cla-backend-go/utils/constants.go b/cla-backend-go/utils/constants.go index 2de570d27..b2ce50800 100644 --- a/cla-backend-go/utils/constants.go +++ b/cla-backend-go/utils/constants.go @@ -219,3 +219,8 @@ const GitLabRepositoryType = "GitLab" // GitHubRepositoryType representing the GitLab repository type const GitHubRepositoryType = "GitHub" + +// ContextKey is the key for the context +type contextKey string + +const XREQUESTIDKey contextKey = "x-request-id" diff --git a/cla-backend-go/v2/sign/docusign.go b/cla-backend-go/v2/sign/docusign.go index da465f4de..24f8a732b 100644 --- a/cla-backend-go/v2/sign/docusign.go +++ b/cla-backend-go/v2/sign/docusign.go @@ -59,7 +59,11 @@ func (s *service) getAccessToken(ctx context.Context) (string, error) { return "", err } - defer resp.Body.Close() + defer func() { + if err = resp.Body.Close(); err != nil { + log.WithFields(f).WithError(err).Warnf("problem closing the response body") + } + }() // Parse the response responsePayload, err := io.ReadAll(resp.Body) diff --git a/cla-backend-go/v2/sign/handlers.go b/cla-backend-go/v2/sign/handlers.go index 3518d5f58..fe279716d 100644 --- a/cla-backend-go/v2/sign/handlers.go +++ b/cla-backend-go/v2/sign/handlers.go @@ -80,7 +80,7 @@ func Configure(api *operations.EasyclaAPI, service Service) { api.SignRequestIndividualSignatureHandler = sign.RequestIndividualSignatureHandlerFunc( func(params sign.RequestIndividualSignatureParams) middleware.Responder { reqId := utils.GetRequestID(params.XREQUESTID) - ctx := context.WithValue(params.HTTPRequest.Context(), utils.XREQUESTID, reqId) + ctx := context.WithValue(params.HTTPRequest.Context(), utils.XREQUESTIDKey, reqId) f := logrus.Fields{ "functionName": "v2.sign.handlers.SignRequestIndividualSignatureHandler", utils.XREQUESTID: ctx.Value(utils.XREQUESTID), diff --git a/cla-backend-go/v2/sign/service.go b/cla-backend-go/v2/sign/service.go index 159035e49..5e91ffc6b 100644 --- a/cla-backend-go/v2/sign/service.go +++ b/cla-backend-go/v2/sign/service.go @@ -11,7 +11,6 @@ import ( "fmt" "io" "net/http" - "os" "strings" "github.com/communitybridge/easycla/cla-backend-go/projects_cla_groups" @@ -35,12 +34,6 @@ import ( "github.com/communitybridge/easycla/cla-backend-go/utils" ) -var ( - integrationKey = os.Getenv("DOCUSIGN_INTEGRATOR_KEY") - userGUID = os.Getenv("DOCUSIGN_USER_ID") - privateKey = os.Getenv("DOCUSIGN_PRIVATE_KEY") -) - // constants const ( DontLoadRepoDetails = false