Skip to content

Commit

Permalink
fix: remove gitlab cloud non-own organization repos (#6438) (#6439)
Browse files Browse the repository at this point in the history
* fix: remove gitlab cloud non-own organization repos

* fix: remove useless code

Co-authored-by: abeizn <zikuan.an@merico.dev>
  • Loading branch information
github-actions[bot] and abeizn committed Nov 10, 2023
1 parent e600477 commit 06ab72e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
6 changes: 5 additions & 1 deletion backend/plugins/gitlab/api/remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,11 @@ func RemoteScopes(input *plugin.ApiResourceInput) (*plugin.ApiResourceOutput, er
var resBody []models.GitlabApiProject
if gid == "" {
var resProjects []models.GitlabApiProject
res, err = apiClient.Get("/projects", query, nil)
if connection.Endpoint == models.GitlabCloudEndPoint {
res, err = apiClient.Get(fmt.Sprintf("users/%d/projects", apiClient.GetData("UserId")), query, nil)
} else {
res, err = apiClient.Get("/projects", query, nil)
}
if err != nil {
return nil, err
}
Expand Down
1 change: 1 addition & 0 deletions backend/plugins/gitlab/models/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ type GitlabConn struct {
api.AccessToken `mapstructure:",squash"`
}

const GitlabCloudEndPoint string = "https://gitlab.com/api/v4/"
const GitlabApiClientData_UserId string = "UserId"
const GitlabApiClientData_ApiVersion string = "ApiVersion"

Expand Down

0 comments on commit 06ab72e

Please sign in to comment.