Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
徐晓伟工作室
gitlab-go
提交
3616ccf5
G
gitlab-go
项目概览
徐晓伟工作室
/
gitlab-go
通知
0
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-go
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
3616ccf5
编写于
10月 09, 2023
作者:
徐晓伟
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
✨
议题 API: 列出议题
上级
c5b69a40
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
98 addition
and
0 deletion
+98
-0
README.md
README.md
+23
-0
constant/common.go
constant/common.go
+2
-0
flag/flag.go
flag/flag.go
+14
-0
issues/issues.go
issues/issues.go
+57
-0
main.go
main.go
+2
-0
未找到文件。
README.md
浏览文件 @
3616ccf5
...
...
@@ -161,6 +161,7 @@ COMMANDS:
access-request, access-requests, ar 群组和项目访问请求 API,中文文档:https://docs.gitlab.cn/jh/api/access_requests.html
board, boards 项目议题板 API,中文文档:https://docs.gitlab.cn/jh/api/boards.html
instance-level-ci-variable, instance-level-ci-variables, ilcv 实例级 CI/CD 变量 API,中文文档:https://docs.gitlab.cn/jh/api/instance_level_ci_variables.html
issue, issues 议题 API,中文文档:https://docs.gitlab.cn/jh/api/issues.html
job-artifact, job-artifacts, ja 作业产物 API,中文文档:https://docs.gitlab.cn/jh/api/job_artifacts.html
job,
jobs
, j 作业 API,中文文档:https://docs.gitlab.cn/jh/api/jobs.html
pipeline, pipelines, pl 流水线 API,中文文档:https://docs.gitlab.cn/jh/api/pipelines.html
...
...
@@ -238,6 +239,28 @@ COPYRIGHT:
--help, -h show help
```
-
[
issue - 议题 API
](
https://docs.gitlab.cn/jh/api/issues.html
)
```shell
$ go run main.go issue --help
NAME:
gitlab-go issue - 议题 API,中文文档:https://docs.gitlab.cn/jh/api/issues.html
USAGE:
gitlab-go issue command [command options] [arguments...]
COMMANDS:
list 列出议题
help, h Shows a list of commands or help for one command
OPTIONS:
--base-url value 实例地址,例如:https://gitlab.xuxiaowei.com.cn/api/v4 (default: "https://gitlab.com/api/v4") [%CI_API_V4_URL%]
--token value your_access_token
--page value 页码(默认:1),中文文档 https://docs.gitlab.cn/jh/api/rest/index.html#pagination (default: 0)
--per-page value 每页列出的项目数(默认:20;最大:100),中文文档 https://docs.gitlab.cn/jh/api/rest/index.html#pagination (default: 0)
--help, -h show help
```
-
[
job-artifact - 作业产物 API
](
https://docs.gitlab.cn/jh/api/job_artifacts.html
)
```shell
...
...
constant/common.go
浏览文件 @
3616ccf5
...
...
@@ -8,4 +8,6 @@ const (
JobId
=
"job-id"
Sort
=
"sort"
SortDefault
=
"desc"
PAGE
=
"page"
PerPage
=
"per-page"
)
flag/flag.go
浏览文件 @
3616ccf5
...
...
@@ -59,3 +59,17 @@ func JobId(required bool) cli.Flag {
Required
:
required
,
}
}
func
Page
()
cli
.
Flag
{
return
&
cli
.
UintFlag
{
Name
:
constant
.
PAGE
,
Usage
:
"页码(默认:1),中文文档 https://docs.gitlab.cn/jh/api/rest/index.html#pagination"
,
}
}
func
PerPage
()
cli
.
Flag
{
return
&
cli
.
UintFlag
{
Name
:
constant
.
PerPage
,
Usage
:
"每页列出的项目数(默认:20;最大:100),中文文档 https://docs.gitlab.cn/jh/api/rest/index.html#pagination"
,
}
}
issues/issues.go
0 → 100644
浏览文件 @
3616ccf5
package
issues
import
(
"encoding/json"
"fmt"
"github.com/urfave/cli/v2"
"github.com/xanzy/go-gitlab"
"github.com/xuxiaowei-com-cn/gitlab-go/constant"
"github.com/xuxiaowei-com-cn/gitlab-go/flag"
"log"
)
// Issues 议题 API https://docs.gitlab.cn/jh/api/issues.html
func
Issues
()
*
cli
.
Command
{
return
&
cli
.
Command
{
Name
:
"issue"
,
Aliases
:
[]
string
{
"issues"
},
Usage
:
"议题 API,中文文档:https://docs.gitlab.cn/jh/api/issues.html"
,
Flags
:
append
(
flag
.
Common
(),
flag
.
Page
(),
flag
.
PerPage
()),
Subcommands
:
[]
*
cli
.
Command
{
{
Name
:
"list"
,
Usage
:
"列出议题"
,
Flags
:
append
(
flag
.
CommonTokenRequired
(),
flag
.
Page
(),
flag
.
PerPage
()),
Action
:
func
(
context
*
cli
.
Context
)
error
{
var
baseUrl
=
context
.
String
(
constant
.
BaseUrl
)
var
token
=
context
.
String
(
constant
.
Token
)
gitClient
,
err
:=
gitlab
.
NewClient
(
token
,
gitlab
.
WithBaseURL
(
baseUrl
))
if
err
!=
nil
{
return
err
}
opt
:=
&
gitlab
.
ListIssuesOptions
{}
issues
,
response
,
err
:=
gitClient
.
Issues
.
ListIssues
(
opt
)
log
.
Printf
(
"Response StatusCode: %d
\n
"
,
response
.
Response
.
StatusCode
)
if
err
!=
nil
{
return
err
}
fmt
.
Println
(
""
)
for
index
,
issue
:=
range
issues
{
jsonData
,
err
:=
json
.
Marshal
(
issue
)
if
err
!=
nil
{
panic
(
err
)
}
log
.
Printf
(
"Index: %d:
\n
%s
\n
"
,
index
,
string
(
jsonData
))
fmt
.
Println
(
""
)
}
return
nil
},
},
},
}
}
main.go
浏览文件 @
3616ccf5
...
...
@@ -6,6 +6,7 @@ import (
"github.com/xuxiaowei-com-cn/gitlab-go/access_requests"
"github.com/xuxiaowei-com-cn/gitlab-go/boards"
"github.com/xuxiaowei-com-cn/gitlab-go/instance_level_ci_variables"
"github.com/xuxiaowei-com-cn/gitlab-go/issues"
"github.com/xuxiaowei-com-cn/gitlab-go/job_artifacts"
"github.com/xuxiaowei-com-cn/gitlab-go/jobs"
"github.com/xuxiaowei-com-cn/gitlab-go/pipelines"
...
...
@@ -66,6 +67,7 @@ func main() {
access_requests
.
AccessRequests
(),
boards
.
Boards
(),
instance_level_ci_variables
.
InstanceLevelCiVariables
(),
issues
.
Issues
(),
job_artifacts
.
JobsArtifacts
(),
jobs
.
Jobs
(),
pipelines
.
Pipelines
(),
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录