Skip to content
This repository has been archived by the owner on Jul 19, 2022. It is now read-only.

Commit

Permalink
Support pushing a manifest list from a layout
Browse files Browse the repository at this point in the history
Bump ggcr to pick up google/go-containerregistry#570.

Build using go 1.12

Fixes #34
  • Loading branch information
glyn committed Oct 16, 2019
1 parent 28a4e87 commit 8acb4ca
Show file tree
Hide file tree
Showing 9 changed files with 250 additions and 25 deletions.
2 changes: 1 addition & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pool:

variables:
GOBIN: '$(GOPATH)/bin' # Go binaries path
GOROOT: '/usr/local/go1.11' # Go installation path
GOROOT: '/usr/local/go1.12' # Go installation path
GOPATH: '$(system.defaultWorkingDirectory)/gopath' # Go workspace path
modulePath: '$(GOPATH)/src/github.com/$(build.repository.name)' # Path to the module's code

Expand Down
13 changes: 5 additions & 8 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,15 @@ module github.com/pivotal/image-relocation
require (
github.com/containerd/containerd v1.2.7 // indirect
github.com/docker/distribution v2.7.0+incompatible
github.com/docker/docker v0.7.3-0.20190811013603-90af4ba5e7fa
github.com/docker/go-connections v0.4.0 // indirect
github.com/docker/docker v1.4.2-0.20180531152204-71cd53e4a197
github.com/docker/go-units v0.4.0 // indirect
github.com/google/go-containerregistry v0.0.0-20190729175742-ef12d49c8daf
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/onsi/ginkgo v1.8.0
github.com/onsi/gomega v1.5.0
github.com/google/go-containerregistry v0.0.0-20191015185424-71da34e4d9b3
github.com/onsi/ginkgo v1.10.1
github.com/onsi/gomega v1.7.0
github.com/opencontainers/go-digest v1.0.0-rc1
github.com/opencontainers/image-spec v1.0.1 // indirect
github.com/pkg/errors v0.8.1
github.com/sirupsen/logrus v1.4.2 // indirect
github.com/spf13/cobra v0.0.3
github.com/spf13/cobra v0.0.5
google.golang.org/grpc v1.22.1 // indirect
k8s.io/apimachinery v0.0.0-20190806215851-162a2dabc72f // indirect
)
Expand Down
84 changes: 84 additions & 0 deletions go.sum

Large diffs are not rendered by default.

12 changes: 9 additions & 3 deletions pkg/registry/ggcr/layout.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@ package ggcr

import (
"fmt"
"github.com/pivotal/image-relocation/pkg/registry"
"os"

"github.com/pivotal/image-relocation/pkg/registry"

"github.com/google/go-containerregistry/pkg/v1"
"github.com/google/go-containerregistry/pkg/v1/empty"
"github.com/google/go-containerregistry/pkg/v1/layout"

"github.com/pivotal/image-relocation/pkg/image"
)

Expand Down Expand Up @@ -85,7 +87,7 @@ func (l *imageLayout) Add(n image.Name) (image.Digest, error) {
annotations := map[string]string{
refNameAnnotation: n.String(),
}
if err:= img.AppendToLayout(l.layoutPath, layout.WithAnnotations(annotations)); err != nil {
if err := img.AppendToLayout(l.layoutPath, layout.WithAnnotations(annotations)); err != nil {
return image.EmptyDigest, err
}

Expand All @@ -108,7 +110,11 @@ func (l *imageLayout) Push(digest image.Digest, n image.Name) error {
}
i, err := imageIndex.Image(hash)
if err != nil {
return err
j, err2 := imageIndex.ImageIndex(hash)
if err2 != nil {
return err
}
return l.registryClient.writeRemoteIndex(j, n)
}

return l.registryClient.writeRemoteImage(i, n)
Expand Down
4 changes: 2 additions & 2 deletions pkg/registry/ggcr/remote_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ var _ = Describe("remote utilities", func() {
Expect(err).NotTo(HaveOccurred())

// In most tests, keychain resolution succeeds
resolveFunc = func(registry name.Registry) (authn.Authenticator, error) {
resolveFunc = func(authn.Resource) (authn.Authenticator, error) {
return nil, nil
}
})

Context("when keychain resolution fails", func() {
BeforeEach(func() {
resolveFunc = func(registry name.Registry) (authn.Authenticator, error) {
resolveFunc = func(authn.Resource) (authn.Authenticator, error) {
return nil, testError
}
})
Expand Down
73 changes: 71 additions & 2 deletions pkg/registry/ggcrfakes/fake_image.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

73 changes: 71 additions & 2 deletions pkg/registry/ggcrfakes/fake_image_index.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions pkg/registry/registryfakes/fake_image.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions pkg/registry/registryfakes/fake_layout_path.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 8acb4ca

Please sign in to comment.