已关闭
feat(actions): 支持 查询指定仓库下的所有 K8S Runner API #442
aflyingto创建于  7月9日关闭于  7月13日
aflyingto成员
7月9日 创建

背景

GitCode API 文档 2.0.0 已提供 Actions API。该 Issue 用于跟踪 gitcode-cli 对此接口的支持设计与实现。

API 摘要

  • 标题: 查询指定仓库下的所有 K8S Runner
  • Method: GET
  • Path: /api/v8/repos/{owner}/{repo}/actions/runner-sets
  • Operation ID: get_api_v8_repos_{owner}_{repo}_actions_runner_sets
  • Tags: pipeline-v8
  • Deprecated: false
  • Description: 无

Request Parameters

Name In Required Type Description
owner path yes string 仓库所属空间地址(组织或个人的地址path)
repo path yes string 仓库路径(path)
access_token query yes string
keyword query no string 关键字过滤
page query no integer 当前页码
per_page query no integer 每页的项目数

Request Body

无。

Responses

200

  • Description: (empty)
  • Headers: 无
  • Content-Types: application/json

application/json schema

{
  "type": "object",
  "properties": {
    "total_count": {
      "type": "integer",
      "description": "RunnerSet 总数"
    },
    "runner_sets": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "RunnerSet ID"
          },
          "runner_group_id": {
            "type": "string",
            "description": "Runner Group ID"
          },
          "name": {
            "type": "string",
            "description": "名称"
          },
          "status": {
            "type": "string",
            "description": "状态,using 使用中  wait_release 释放中"
          },
          "required_labels": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "label_name": {
                  "type": "string",
                  "description": "标签名称"
                },
                "label_value": {
                  "type": "string",
                  "description": "标签值"
                },
                "label_color": {
                  "type": "string",
                  "description": "标签颜色"
                }
              },
              "description": "必需标签"
            },
            "description": "必需标签"
          },
          "min_runner_size": {
            "type": "integer",
            "description": "最小 Runner 数量"
          },
          "max_runner_size": {
            "type": "integer",
            "description": "最大 Runner 数量"
          },
          "limit_cpu": {
            "type": "integer",
            "description": "CPU 限制"
          },
          "limit_memory": {
            "type": "integer",
            "description": "内存限制"
          },
          "image_name": {
            "type": "string",
            "description": "镜像名称"
          },
          "user_k8s_cluster_id": {
            "type": "string",
            "description": "用户 K8S 集群 ID"
          },
          "user_k8s_cluster_name": {
            "type": "string",
            "description": "用户 K8S 集群名称"
          },
          "user_k8s_resource_type": {
            "type": "string",
            "description": "用户 K8S 资源类型"
          },
          "user_k8s_cluster_namespace": {
            "type": "string",
            "description": "用户 K8S 命名空间"
          },
          "user_k8s_url": {
            "type": "string",
            "description": "用户 K8S 地址"
          },
          "create_time": {
            "type": "integer",
            "description": "创建时间"
          },
          "update_time": {
            "type": "integer",
            "description": "更新时间"
          },
          "user_id": {
            "type": "string",
            "description": "用户 ID"
          },
          "user_name": {
            "type": "string",
            "description": "用户名"
          },
          "user_project_id": {
            "type": "string",
            "description": "用户项目 ID"
          }
        },
        "description": "RunnerSet 列表"
      },
      "description": "RunnerSet 列表"
    }
  },
  "description": "com.gitcode.openapi.pojo.action.runner.BizK8sRunnerSetListResp"
}

原始 OpenAPI Operation

{
  "deprecated": false,
  "description": "",
  "operationId": "get_api_v8_repos_{owner}_{repo}_actions_runner_sets",
  "tags": [
    "pipeline-v8"
  ],
  "parameters": [
    {
      "name": "owner",
      "in": "path",
      "description": "仓库所属空间地址(组织或个人的地址path)",
      "required": true,
      "schema": {
        "type": "string"
      }
    },
    {
      "name": "repo",
      "in": "path",
      "description": "仓库路径(path)",
      "required": true,
      "schema": {
        "type": "string"
      }
    },
    {
      "name": "access_token",
      "in": "query",
      "description": "",
      "required": true,
      "schema": {
        "type": "string"
      }
    },
    {
      "name": "keyword",
      "in": "query",
      "description": "关键字过滤",
      "example": "",
      "schema": {
        "type": "string"
      }
    },
    {
      "name": "page",
      "in": "query",
      "description": "当前页码",
      "example": 1,
      "schema": {
        "type": "integer"
      }
    },
    {
      "name": "per_page",
      "in": "query",
      "description": "每页的项目数",
      "example": 10,
      "schema": {
        "type": "integer"
      }
    }
  ],
  "responses": {
    "200": {
      "description": "",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "properties": {
              "total_count": {
                "type": "integer",
                "description": "RunnerSet 总数"
              },
              "runner_sets": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "RunnerSet ID"
                    },
                    "runner_group_id": {
                      "type": "string",
                      "description": "Runner Group ID"
                    },
                    "name": {
                      "type": "string",
                      "description": "名称"
                    },
                    "status": {
                      "type": "string",
                      "description": "状态,using 使用中  wait_release 释放中"
                    },
                    "required_labels": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "label_name": {
                            "type": "string",
                            "description": "标签名称"
                          },
                          "label_value": {
                            "type": "string",
                            "description": "标签值"
                          },
                          "label_color": {
                            "type": "string",
                            "description": "标签颜色"
                          }
                        },
                        "description": "必需标签"
                      },
                      "description": "必需标签"
                    },
                    "min_runner_size": {
                      "type": "integer",
                      "description": "最小 Runner 数量"
                    },
                    "max_runner_size": {
                      "type": "integer",
                      "description": "最大 Runner 数量"
                    },
                    "limit_cpu": {
                      "type": "integer",
                      "description": "CPU 限制"
                    },
                    "limit_memory": {
                      "type": "integer",
                      "description": "内存限制"
                    },
                    "image_name": {
                      "type": "string",
                      "description": "镜像名称"
                    },
                    "user_k8s_cluster_id": {
                      "type": "string",
                      "description": "用户 K8S 集群 ID"
                    },
                    "user_k8s_cluster_name": {
                      "type": "string",
                      "description": "用户 K8S 集群名称"
                    },
                    "user_k8s_resource_type": {
                      "type": "string",
                      "description": "用户 K8S 资源类型"
                    },
                    "user_k8s_cluster_namespace": {
                      "type": "string",
                      "description": "用户 K8S 命名空间"
                    },
                    "user_k8s_url": {
                      "type": "string",
                      "description": "用户 K8S 地址"
                    },
                    "create_time": {
                      "type": "integer",
                      "description": "创建时间"
                    },
                    "update_time": {
                      "type": "integer",
                      "description": "更新时间"
                    },
                    "user_id": {
                      "type": "string",
                      "description": "用户 ID"
                    },
                    "user_name": {
                      "type": "string",
                      "description": "用户名"
                    },
                    "user_project_id": {
                      "type": "string",
                      "description": "用户项目 ID"
                    }
                  },
                  "description": "RunnerSet 列表"
                },
                "description": "RunnerSet 列表"
              }
            },
            "description": "com.gitcode.openapi.pojo.action.runner.BizK8sRunnerSetListResp"
          }
        }
      },
      "headers": {}
    }
  },
  "security": [],
  "method": "get",
  "path": "/api/v8/repos/{owner}/{repo}/actions/runner-sets",
  "servers": [
    {
      "url": "https://api.gitcode.com",
      "description": "正式环境"
    }
  ],
  "securitySchemes": {},
  "info": {
    "title": "GicodeOpenAPI",
    "description": "",
    "version": "1.0.0"
  },
  "postman": {
    "name": "查询指定仓库下的所有 K8S Runner",
    "description": {
      "content": "",
      "type": "text/plain"
    },
    "url": {
      "path": [
        "api",
        "v8",
        "repos",
        ":owner",
        ":repo",
        "actions",
        "runner-sets"
      ],
      "host": [
        "{{baseUrl}}"
      ],
      "query": [
        {
          "disabled": false,
          "description": {
            "content": "(Required) ",
            "type": "text/plain"
          },
          "key": "access_token",
          "value": ""
        },
        {
          "disabled": false,
          "description": {
            "content": "关键字过滤",
            "type": "text/plain"
          },
          "key": "keyword",
          "value": ""
        },
        {
          "disabled": false,
          "description": {
            "content": "当前页码",
            "type": "text/plain"
          },
          "key": "page",
          "value": ""
        },
        {
          "disabled": false,
          "description": {
            "content": "每页的项目数",
            "type": "text/plain"
          },
          "key": "per_page",
          "value": ""
        }
      ],
      "variable": [
        {
          "disabled": false,
          "description": {
            "content": "(Required) 仓库所属空间地址(组织或个人的地址path)",
            "type": "text/plain"
          },
          "type": "any",
          "value": "",
          "key": "owner"
        },
        {
          "disabled": false,
          "description": {
            "content": "(Required) 仓库路径(path)",
            "type": "text/plain"
          },
          "type": "any",
          "value": "",
          "key": "repo"
        }
      ]
    },
    "header": [
      {
        "key": "Accept",
        "value": "application/json"
      }
    ],
    "method": "GET"
  }
}

初步验收建议

  • 增加对应 API client/query 方法,保留 v8 路径。
  • 设计 agent-friendly 的 CLI 命令、帮助文本、JSON 输出和错误处理。
  • 单元测试覆盖参数映射、响应解析和错误路径。
  • 如做真实命令验证,只能使用 infra-test/* 仓库。
  • 不暴露或打印 token;文档中的 access_token 仅作为 API 参数记录,CLI 优先复用现有认证机制。
likedislike
Aaflyingto成员
7月9日 添加了label:risk/mediumscope/api, status/triage,type/feature
Aaflyingto成员
7月9日 关联了里程碑:Actions M3: Runner 管理
Aaflyingto成员
7月9日 添加了label:featurescope/actions
Aaflyingto成员
7月9日 删除了label:feature
aflyingto成员
7月13日 评论:

验证记录

  • 当前版本或分支: main
  • 复现命令: gc api --method GET "/api/v8/repos/infra-test/gctest1/actions/runner-sets?per_page=10&page=1"
  • 实际结果: {"total_count":0,"runner_sets":[]} — API 端点可达,返回有效 JSON
  • API 规格: GET /api/v8/repos/{owner}/{repo}/actions/runner-sets,返回 {total_count, runner_sets: [{id, runner_group_id, name, status, required_labels}]}
  • 结论: 需求有效,API 可达,进入修复
likedislike
Aaflyingto成员
7月13日 删除了label:status/triage
Aaflyingto成员
7月13日 添加了label:status/verified
Aaflyingto成员
7月13日 添加了label:status/in-progress
Aaflyingto成员
7月13日 关联了pull request:feat(actions): add gc actions runner-set list for listing repo K8S runner sets
Aaflyingto成员
7月13日 关闭了 issue
Aaflyingto成员
7月13日 删除了label:status/in-progress
Aaflyingto成员
7月13日 删除了label:status/verified
Aaflyingto成员
7月13日 添加了label:status/merged