You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by he...@apache.org on 2022/07/14 19:30:12 UTC
[incubator-devlake] branch main updated: feat(github): return relevent status inside body when return login (#2498)
This is an automated email from the ASF dual-hosted git repository.
hez 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 1f8c513b feat(github): return relevent status inside body when return login (#2498)
1f8c513b is described below
commit 1f8c513b5af4d84fcea988c142216a64598c6f44
Author: Warren Chen <yi...@merico.dev>
AuthorDate: Fri Jul 15 03:30:06 2022 +0800
feat(github): return relevent status inside body when return login (#2498)
closes #2497
---
plugins/github/api/connection.go | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/plugins/github/api/connection.go b/plugins/github/api/connection.go
index 559f5d41..ebfec4c1 100644
--- a/plugins/github/api/connection.go
+++ b/plugins/github/api/connection.go
@@ -20,6 +20,7 @@ package api
import (
"context"
"fmt"
+ "github.com/apache/incubator-devlake/api/shared"
"net/http"
"time"
@@ -60,8 +61,6 @@ func TestConnection(input *core.ApiResourceInput) (*core.ApiResourceOutput, erro
if err != nil {
return nil, err
}
- // verify multiple token in parallel
- // PLEASE NOTE: This works because GitHub API Client rotates tokens on each request
apiClient, err := helper.NewApiClient(
context.TODO(),
params.Endpoint,
@@ -78,13 +77,20 @@ func TestConnection(input *core.ApiResourceInput) (*core.ApiResourceOutput, erro
if err != nil {
return nil, err
}
- githubApiResponse := &models.GithubUserOfToken{}
- err = helper.UnmarshalResponse(res, githubApiResponse)
+ var githubApiResponse struct {
+ shared.ApiBody
+ Login string `json:"login"`
+ }
+ githubUserOfToken := &models.GithubUserOfToken{}
+ err = helper.UnmarshalResponse(res, githubUserOfToken)
if err != nil {
return nil, err
- } else if githubApiResponse.Login == "" {
+ } else if githubUserOfToken.Login == "" {
return nil, fmt.Errorf("invalid token")
}
+ githubApiResponse.Success = true
+ githubApiResponse.Message = "success"
+ githubApiResponse.Login = githubUserOfToken.Login
// output
return &core.ApiResourceOutput{Body: githubApiResponse, Status: http.StatusOK}, nil