Skip to content

Commit

Permalink
bump ggcr dep to v0.5.0 (#349)
Browse files Browse the repository at this point in the history
  • Loading branch information
imjasonh committed Apr 28, 2021
1 parent 938bbcd commit 5395f99
Show file tree
Hide file tree
Showing 66 changed files with 1,166 additions and 557 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ require (
github.com/fsnotify/fsnotify v1.4.9
github.com/go-training/helloworld v0.0.0-20200225145412-ba5f4379d78b
github.com/google/go-cmp v0.5.4
github.com/google/go-containerregistry v0.4.1-0.20210216200643-d81088d9983e
github.com/google/go-containerregistry v0.5.0
github.com/gregjones/httpcache v0.0.0-20190212212710-3befbb6ad0cc // indirect
github.com/mattmoor/dep-notify v0.0.0-20190205035814-a45dec370a17
github.com/onsi/gomega v1.10.3 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,8 @@ github.com/google/go-cmp v0.5.4 h1:L8R9j+yAqZuZjsqh/z+F1NCffTKKLShY6zXTItVIZ8M=
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-containerregistry v0.4.1-0.20210216200643-d81088d9983e h1:8jPkeUOUhBGSDpuIUyjKHsC0I5/nI4zvmv6DB2TACh4=
github.com/google/go-containerregistry v0.4.1-0.20210216200643-d81088d9983e/go.mod h1:Ct15B4yir3PLOP5jsy0GNeYVaIZs/MK/Jz5any1wFW0=
github.com/google/go-containerregistry v0.5.0 h1:eb9sinv4PKm0AUwQGov0mvIdA4pyBGjRofxN4tWnMwM=
github.com/google/go-containerregistry v0.5.0/go.mod h1:Ct15B4yir3PLOP5jsy0GNeYVaIZs/MK/Jz5any1wFW0=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/gofuzz v1.1.0 h1:Hsa8mG0dQ46ij8Sl2AYJDUv1oA9/d6Vk+3LG99Oe02g=
github.com/google/gofuzz v1.1.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
Expand Down
13 changes: 8 additions & 5 deletions pkg/publish/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,13 @@ func NewDaemon(namer Namer, tags []string) Interface {
return &demon{namer, tags}
}

// getOpts returns daemon.Options. It's a var to allow it to be overridden during tests.
var getOpts = func(ctx context.Context) []daemon.Option {
return []daemon.Option{daemon.WithContext(ctx)}
}

// Publish implements publish.Interface
func (d *demon) Publish(_ context.Context, br build.Result, s string) (name.Reference, error) {
func (d *demon) Publish(ctx context.Context, br build.Result, s string) (name.Reference, error) {
s = strings.TrimPrefix(s, build.StrictScheme)
// https://github.com/google/go-containerregistry/issues/212
s = strings.ToLower(s)
Expand Down Expand Up @@ -100,7 +105,7 @@ func (d *demon) Publish(_ context.Context, br build.Result, s string) (name.Refe
}

log.Printf("Loading %v", digestTag)
if _, err := daemon.Write(digestTag, img); err != nil {
if _, err := daemon.Write(digestTag, img, getOpts(ctx)...); err != nil {
return nil, err
}
log.Printf("Loaded %v", digestTag)
Expand All @@ -112,9 +117,7 @@ func (d *demon) Publish(_ context.Context, br build.Result, s string) (name.Refe
return nil, err
}

err = daemon.Tag(digestTag, tag)

if err != nil {
if err := daemon.Tag(digestTag, tag, getOpts(ctx)...); err != nil {
return nil, err
}
log.Printf("Added tag %v", tagName)
Expand Down
22 changes: 14 additions & 8 deletions pkg/publish/daemon_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,30 @@ import (
"github.com/google/go-containerregistry/pkg/v1/random"
)

type MockImageLoader struct{}

var Tags []string
type mockClient struct {
daemon.Client
}

func (m *MockImageLoader) ImageLoad(_ context.Context, _ io.Reader, _ bool) (types.ImageLoadResponse, error) {
func (m *mockClient) NegotiateAPIVersion(context.Context) {}
func (m *mockClient) ImageLoad(context.Context, io.Reader, bool) (types.ImageLoadResponse, error) {
return types.ImageLoadResponse{
Body: ioutil.NopCloser(strings.NewReader("Loaded")),
}, nil
}

func (m *MockImageLoader) ImageTag(ctx context.Context, source, target string) error {
Tags = append(Tags, target)
func (m *mockClient) ImageTag(_ context.Context, _ string, tag string) error {
Tags = append(Tags, tag)
return nil
}

var Tags []string

func init() {
daemon.GetImageLoader = func() (daemon.ImageLoader, error) {
return &MockImageLoader{}, nil
getOpts = func(ctx context.Context) []daemon.Option {
return []daemon.Option{
daemon.WithContext(ctx),
daemon.WithClient(&mockClient{}),
}
}
}

Expand Down

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

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

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

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

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

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

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

0 comments on commit 5395f99

Please sign in to comment.