容器仓库 API: 删除仓库里存储库的某个标签

This commit is contained in:
徐晓伟 2023-10-15 20:52:15 +08:00
parent 44b13338a3
commit f3787e5871
2 changed files with 32 additions and 4 deletions

View File

@ -231,10 +231,11 @@ COPYRIGHT:
gitlab-go container-registry command [command options] [arguments...]
COMMANDS:
list 列出仓库内存储库
list-tags 列出仓库里存储库的标签
get-tag 获取仓库里存储库的某个标签的详情
help, h Shows a list of commands or help for one command
list 列出仓库内存储库
list-tags 列出仓库里存储库的标签
get-tag 获取仓库里存储库的某个标签的详情
delete-tag, rm-tag 删除仓库里存储库的某个标签
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%]

View File

@ -261,6 +261,33 @@ func ContainerRegistry() *cli.Command {
}
}
return nil
},
},
{
Name: "delete-tag",
Aliases: []string{"rm-tag"},
Usage: "删除仓库里存储库的某个标签",
Flags: append(flag.CommonTokenRequired(),
flag.Id(true), flag.Repository(true), flag.TagName(true)),
Action: func(context *cli.Context) error {
var baseUrl = context.String(constant.BaseUrl)
var token = context.String(constant.Token)
var id = context.String(constant.Id)
var repository = context.Int(constant.Repository)
var tagName = context.String(constant.TagName)
gitClient, err := gitlab.NewClient(token, gitlab.WithBaseURL(baseUrl))
if err != nil {
return err
}
response, err := gitClient.ContainerRegistry.DeleteRegistryRepositoryTag(id, repository, tagName)
log.Printf("Response StatusCode: %d\n", response.Response.StatusCode)
if err != nil {
return err
}
return nil
},
},