Keval Bhogayata
Keval Bhogayata

Reputation: 6736

How to extract list of docker images inside GCP artifact registry

I want to list all the repositories inside GCP artifact registry in golang.

Current code : (https://pkg.go.dev/cloud.google.com/go/artifactregistry/apiv1beta2)

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

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

The error prints: Invalid field value in the request. OR sometimes I get Request contains an invalid argument

What am I doing wrong here ? and What does the "Parent" mean ? (in ListRepositoriesRequest)

On further digging, I found that the value passed in the Parent goes to : "x-goog-request-params", what should be the correct format for this ?

Upvotes: 2

Views: 1528

Answers (1)

guillaume blaquiere
guillaume blaquiere

Reputation: 76000

Sometime the libraries/api are well documented, sometime not...

Here the REST API that you can test in the API explorer (right hand side bar). After some tests, the parent must have that format

projects/<PROJECT_ID>/locations/<REGION>

Try with that to solve your issue

Upvotes: 3

Related Questions