登录
首页 >  Golang >  Go问答

提取 GCP 工件注册表中的 Docker 镜像列表的方法

来源:stackoverflow

时间:2024-03-09 20:54:25 392浏览 收藏

各位小伙伴们,大家好呀!看看今天我又给各位带来了什么文章?本文标题《提取 GCP 工件注册表中的 Docker 镜像列表的方法》,很明显是关于Golang的文章哈哈哈,其中内容主要会涉及到等等,如果能帮到你,觉得很不错的话,欢迎各位多多点评和分享!

问题内容

我想列出 golang 中 gcp 工件注册表内的所有存储库。

当前代码:(https://pkg.go.dev/cloud.google.com/go/artifactregistry/apiv1beta2)

c, err := artifactregistry.NewClient(ctx, option.WithCredentialsFile(""))
    if err != nil {
        // no error here
    }
    defer c.Close()

    req := &artifactregistrypb.ListRepositoriesRequest{
        Parent: "",
    }
    it := c.ListRepositories(ctx, req)
    for {
        resp, err := it.Next()
        if err == nil {
            fmt.Println("resp", resp)
        } else {
            fmt.Println("err ==>", err)
        }
    }

错误打印:请求中的字段值无效。或者有时我得到request包含无效参数

我在这里做错了什么? “父母”是什么意思? (在 listrepositoriesrequest 中)

在进一步挖掘中,我发现在父级中传递的值变为:“x-goog-request-params”,正确的格式应该是什么?


正确答案


有时库/api 有详细记录,有时则没有......

Here the REST API,您可以在 api 资源管理器(右侧栏)中进行测试。经过一些测试,父级必须具有该格式

projects//locations/

尝试用它来解决您的问题

到这里,我们也就讲完了《提取 GCP 工件注册表中的 Docker 镜像列表的方法》的内容了。个人认为,基础知识的学习和巩固,是为了更好的将其运用到项目中,欢迎关注golang学习网公众号,带你了解更多关于的知识点!

声明:本文转载于:stackoverflow 如有侵犯,请联系study_golang@163.com删除
相关阅读
更多>
最新阅读
更多>
课程推荐
更多>