I am using the following code to list my docker repositories that are available in GCR
package main
import (
"context"
"fmt"
"log"
"github.com/google/go-containerregistry/pkg/authn"
gcr "github.com/google/go-containerregistry/pkg/name"
"github.com/google/go-containerregistry/pkg/v1/google"
"github.com/google/go-containerregistry/pkg/v1/remote"
)
func main() {
auth, err := google.NewGcloudAuthenticator()
if err != nil {
log.Fatal(err)
}
fmt.Println(auth)
registry, err := gcr.NewRegistry("gcr.io")
if err != nil {
log.Fatal(err)
}
ctx := context.Background()
repos, err := remote.Catalog(ctx, registry, remote.WithAuthFromKeychain(authn.DefaultKeychain))
if err != nil {
log.Fatal(err)
}
for _, repoName := range repos {
fmt.Println(repoName)
}
}
The problem is that despite the fact that I have performed an explicit gcloud config set project to a specific project, invocation of the above program will list ALL repos of ALL organizations and ALL projects my gcloud has access to.
Is there a way to limit the code above so that it lists the gcr repos of a specific org/project?