This is an automated email from the ASF dual-hosted git repository.

zhangliang2022 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git


The following commit(s) were added to refs/heads/main by this push:
     new 0dd759ae6 refactor: simplify jira apiclient creation (#4319)
0dd759ae6 is described below

commit 0dd759ae68c6745a641c214f15ba5c0597b9a222
Author: Klesh Wong <[email protected]>
AuthorDate: Fri Feb 3 19:18:46 2023 +0800

    refactor: simplify jira apiclient creation (#4319)
---
 backend/plugins/jira/api/connection.go    | 2 +-
 backend/plugins/jira/models/connection.go | 4 ++--
 backend/plugins/jira/tasks/api_client.go  | 9 +++------
 3 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/backend/plugins/jira/api/connection.go 
b/backend/plugins/jira/api/connection.go
index 41640c588..1554422bc 100644
--- a/backend/plugins/jira/api/connection.go
+++ b/backend/plugins/jira/api/connection.go
@@ -52,7 +52,7 @@ func TestConnection(input *plugin.ApiResourceInput) 
(*plugin.ApiResourceOutput,
                return nil, errors.Convert(e)
        }
        // test connection
-       apiClient, err := api.NewApiClientFromConnection(context.TODO(), 
basicRes, connection)
+       apiClient, err := api.NewApiClientFromConnection(context.TODO(), 
basicRes, &connection)
        if err != nil {
                return nil, err
        }
diff --git a/backend/plugins/jira/models/connection.go 
b/backend/plugins/jira/models/connection.go
index eb412c1f2..8e79a0aee 100644
--- a/backend/plugins/jira/models/connection.go
+++ b/backend/plugins/jira/models/connection.go
@@ -46,8 +46,8 @@ type JiraConn struct {
 
 // SetupAuthentication implements the `IAuthentication` interface by delegating
 // the actual logic to the `MultiAuth` struct to help us write less code
-func (jc JiraConn) SetupAuthentication(req *http.Request) errors.Error {
-       return jc.MultiAuth.SetupAuthenticationForConnection(&jc, req)
+func (jc *JiraConn) SetupAuthentication(req *http.Request) errors.Error {
+       return jc.MultiAuth.SetupAuthenticationForConnection(jc, req)
 }
 
 // JiraConnection holds JiraConn plus ID/Name for database storage
diff --git a/backend/plugins/jira/tasks/api_client.go 
b/backend/plugins/jira/tasks/api_client.go
index 6510ffa34..2062645b6 100644
--- a/backend/plugins/jira/tasks/api_client.go
+++ b/backend/plugins/jira/tasks/api_client.go
@@ -19,20 +19,17 @@ package tasks
 
 import (
        "fmt"
+       "net/http"
+
        "github.com/apache/incubator-devlake/core/errors"
        "github.com/apache/incubator-devlake/core/plugin"
        "github.com/apache/incubator-devlake/helpers/pluginhelper/api"
        "github.com/apache/incubator-devlake/plugins/jira/models"
-       "net/http"
 )
 
 func NewJiraApiClient(taskCtx plugin.TaskContext, connection 
*models.JiraConnection) (*api.ApiAsyncClient, errors.Error) {
        // create synchronize api client so we can calculate api rate limit 
dynamically
-       headers := map[string]string{
-               "Authorization": fmt.Sprintf("Basic %v", 
connection.GetEncodedToken()),
-       }
-
-       apiClient, err := api.NewApiClient(taskCtx.GetContext(), 
connection.Endpoint, headers, 0, connection.Proxy, taskCtx)
+       apiClient, err := api.NewApiClientFromConnection(taskCtx.GetContext(), 
taskCtx, connection)
        if err != nil {
                return nil, err
        }

Reply via email to