Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Tarball publisher types private and return Interface. #182

Merged
merged 1 commit into from
Aug 12, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions pkg/publish/tarball.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"github.com/google/ko/pkg/build"
)

type TarballPublisher struct {
type tar struct {
file string
base string
namer Namer
Expand All @@ -34,8 +34,8 @@ type TarballPublisher struct {
}

// NewTarball returns a new publish.Interface that saves images to a tarball.
func NewTarball(file, base string, namer Namer, tags []string) *TarballPublisher {
return &TarballPublisher{
func NewTarball(file, base string, namer Namer, tags []string) Interface {
return &tar{
file: file,
base: base,
namer: namer,
Expand All @@ -45,7 +45,7 @@ func NewTarball(file, base string, namer Namer, tags []string) *TarballPublisher
}

// Publish implements publish.Interface.
func (t *TarballPublisher) Publish(img v1.Image, s string) (name.Reference, error) {
func (t *tar) Publish(img v1.Image, 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 @@ -85,7 +85,7 @@ func (t *TarballPublisher) Publish(img v1.Image, s string) (name.Reference, erro
return &dig, nil
}

func (t *TarballPublisher) Close() error {
func (t *tar) Close() error {
log.Printf("Saving %v", t.file)
if err := tarball.MultiRefWriteToFile(t.file, t.refs); err != nil {
// Bad practice, but we log this here because right now we just defer the Close.
Expand Down