You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by li...@apache.org on 2023/02/10 13:48:08 UTC

[incubator-devlake] branch main updated: fix: github test connection not working (#4385)

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

likyh 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 d0fc26f48 fix: github test connection not working (#4385)
d0fc26f48 is described below

commit d0fc26f489647584dd69cf827fc56dfe695002a6
Author: Klesh Wong <zh...@merico.dev>
AuthorDate: Fri Feb 10 21:48:02 2023 +0800

    fix: github test connection not working (#4385)
    
    * fix: github test connection not working
    
    * feat: make sure connection is a pointer in NewApiClientFromConnection
---
 backend/helpers/pluginhelper/api/api_client.go | 4 ++++
 backend/plugins/github/api/connection.go       | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/backend/helpers/pluginhelper/api/api_client.go b/backend/helpers/pluginhelper/api/api_client.go
index c2688bf16..96e4bae83 100644
--- a/backend/helpers/pluginhelper/api/api_client.go
+++ b/backend/helpers/pluginhelper/api/api_client.go
@@ -26,6 +26,7 @@ import (
 	"io"
 	"net/http"
 	"net/url"
+	"reflect"
 	"regexp"
 	"strings"
 	"time"
@@ -59,6 +60,9 @@ func NewApiClientFromConnection(
 	br context.BasicRes,
 	connection aha.ApiConnection,
 ) (*ApiClient, errors.Error) {
+	if reflect.ValueOf(connection).Kind() != reflect.Ptr {
+		return nil, errors.Default.New("connection is not a pointer")
+	}
 	apiClient, err := NewApiClient(ctx, connection.GetEndpoint(), nil, 0, connection.GetProxy(), br)
 	if err != nil {
 		return nil, err
diff --git a/backend/plugins/github/api/connection.go b/backend/plugins/github/api/connection.go
index 958328311..91dd3420f 100644
--- a/backend/plugins/github/api/connection.go
+++ b/backend/plugins/github/api/connection.go
@@ -49,7 +49,7 @@ func TestConnection(input *plugin.ApiResourceInput) (*plugin.ApiResourceOutput,
 		return nil, err
 	}
 
-	apiClient, err := api.NewApiClientFromConnection(context.TODO(), basicRes, conn)
+	apiClient, err := api.NewApiClientFromConnection(context.TODO(), basicRes, &conn)
 	if err != nil {
 		return nil, err
 	}