1
0
mirror of https://github.com/woodpecker-ci/woodpecker.git synced 2026-06-03 16:35:37 +02:00

Fix parsing /user/workspaces response (#6396)

This commit is contained in:
Lê Hoàng Phương
2026-04-07 16:17:28 +09:00
committed by GitHub
parent ff51601674
commit 5cf626cef9
3 changed files with 37 additions and 21 deletions
+13 -2
View File
@@ -160,7 +160,13 @@ func (c *config) Teams(ctx context.Context, u *model.User, p *model.ListOptions)
if err != nil {
return nil, err
}
return convertWorkspaceList(resp.Values), nil
var workspaces []*internal.Workspace
for _, access := range resp.Values {
if access.Workspace != nil {
workspaces = append(workspaces, access.Workspace)
}
}
return convertWorkspaceList(workspaces), nil
}
// Repo returns the named Bitbucket repository.
@@ -214,7 +220,12 @@ func (c *config) Repos(ctx context.Context, u *model.User, p *model.ListOptions)
}
var all []*model.Repo
for _, workspace := range resp.Values {
for _, access := range resp.Values {
if access.Workspace == nil {
continue
}
workspace := access.Workspace
repos, err := client.ListReposAll(workspace.Slug)
if err != nil {
return nil, err
+13 -13
View File
@@ -534,19 +534,19 @@ const workspacesPayload = `
"size": 1,
"values": [
{
"type": "workspace",
"uuid": "{c7a04a76-fa20-43e4-dc42-a7506db4c95b}",
"name": "Ueber Dev",
"slug": "test_name",
"links": {
"avatar": {
"href": "https://bitbucket.org/workspaces/ueberdev42/avatar/?ts=1658761964"
},
"html": {
"href": "https://bitbucket.org/ueberdev42/"
},
"self": {
"href": "https://api.bitbucket.org/2.0/workspaces/ueberdev42"
"type": "workspace_access",
"administrator": true,
"workspace": {
"type": "workspace_base",
"uuid": "{c7a04a76-fa20-43e4-dc42-a7506db4c95b}",
"slug": "test_name",
"links": {
"avatar": {
"href": "https://bitbucket.org/workspaces/ueberdev42/avatar/?ts=1658761964"
},
"self": {
"href": "https://api.bitbucket.org/2.0/workspaces/ueberdev42"
}
}
}
}
+11 -6
View File
@@ -33,17 +33,22 @@ type Account struct {
type Workspace struct {
UUID string `json:"uuid"`
Slug string `json:"slug"`
Name string `json:"name"`
Type string `json:"type"`
Links Links `json:"links"`
}
type WorkspaceAccess struct {
Type string `json:"type"`
Administrator bool `json:"administrator"`
Workspace *Workspace `json:"workspace"`
}
type WorkspacesResp struct {
Page int `json:"page"`
Pages int `json:"pagelen"`
Size int `json:"size"`
Next string `json:"next"`
Values []*Workspace `json:"values"`
Page int `json:"page"`
Pages int `json:"pagelen"`
Size int `json:"size"`
Next string `json:"next"`
Values []*WorkspaceAccess `json:"values"`
}
type PipelineStatus struct {