grim/tagpull

1662950b867d
Parents b23e8d5837de
Children 43b03be98fab
Create the registry once since it is using anonymous authentication.
  • +14 -6
    registry.go
  • --- a/registry.go Sun Jul 05 06:03:07 2020 -0500
    +++ b/registry.go Sun Jul 05 06:03:46 2020 -0500
    @@ -6,18 +6,26 @@
    "github.com/heroku/docker-registry-client/registry"
    )
    -func registryGetDigest(repository, tag string) (string, error) {
    - reg, err := registry.New("https://index.docker.io", "", "")
    +var (
    + reg *registry.Registry
    +)
    +
    +func init() {
    + r, err := registry.New("https://index.docker.io", "", "")
    if err != nil {
    - return "", err
    + panic(err)
    }
    + // disable the logger on the registry
    + r.Logf = func(format string, args ...interface{}) {}
    +
    + reg = r
    +}
    +
    +func registryGetDigest(repository, tag string) (string, error) {
    // make sure the repository doesn't have a tag
    repository = strings.SplitN(repository, ":", 2)[0]
    - // disable the logger on the registry
    - reg.Logf = func(format string, args ...interface{}) {}
    -
    manifest, err := reg.ManifestV2(repository, tag)
    if err != nil {
    return "", err