diff --git a/pkg/publish/default.go b/pkg/publish/default.go index 23604b00a6..985b50001c 100644 --- a/pkg/publish/default.go +++ b/pkg/publish/default.go @@ -24,6 +24,7 @@ import ( "github.com/google/go-containerregistry/pkg/name" v1 "github.com/google/go-containerregistry/pkg/v1" "github.com/google/go-containerregistry/pkg/v1/remote" + "github.com/google/ko/pkg/build" ) // defalt is intentionally misspelled to avoid keyword collision (and drive Jon nuts). @@ -95,6 +96,7 @@ func NewDefault(base string, options ...Option) (Interface, error) { // Publish implements publish.Interface func (d *defalt) 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) diff --git a/pkg/publish/default_test.go b/pkg/publish/default_test.go index aa98c59833..e941b25af9 100644 --- a/pkg/publish/default_test.go +++ b/pkg/publish/default_test.go @@ -26,6 +26,7 @@ import ( "github.com/google/go-containerregistry/pkg/name" "github.com/google/go-containerregistry/pkg/v1/random" + "github.com/google/ko/pkg/build" ) func TestDefault(t *testing.T) { @@ -77,7 +78,7 @@ func TestDefault(t *testing.T) { if err != nil { t.Errorf("NewDefault() = %v", err) } - if d, err := def.Publish(img, importpath); err != nil { + if d, err := def.Publish(img, build.StrictScheme+importpath); err != nil { t.Errorf("Publish() = %v", err) } else if !strings.HasPrefix(d.String(), tag.Repository.String()) { t.Errorf("Publish() = %v, wanted prefix %v", d, tag.Repository) @@ -141,7 +142,7 @@ func TestDefaultWithCustomNamer(t *testing.T) { if err != nil { t.Errorf("NewDefault() = %v", err) } - if d, err := def.Publish(img, importpath); err != nil { + if d, err := def.Publish(img, build.StrictScheme+importpath); err != nil { t.Errorf("Publish() = %v", err) } else if !strings.HasPrefix(d.String(), repoName) { t.Errorf("Publish() = %v, wanted prefix %v", d, tag.Repository) @@ -205,7 +206,7 @@ func TestDefaultWithTags(t *testing.T) { if err != nil { t.Errorf("NewDefault() = %v", err) } - if d, err := def.Publish(img, importpath); err != nil { + if d, err := def.Publish(img, build.StrictScheme+importpath); err != nil { t.Errorf("Publish() = %v", err) } else if !strings.HasPrefix(d.String(), repoName) { t.Errorf("Publish() = %v, wanted prefix %v", d, tag.Repository) @@ -278,7 +279,7 @@ func TestDefaultWithReleaseTag(t *testing.T) { if err != nil { t.Errorf("NewDefault() = %v", err) } - if d, err := def.Publish(img, importpath); err != nil { + if d, err := def.Publish(img, build.StrictScheme+importpath); err != nil { t.Errorf("Publish() = %v", err) } else if !strings.HasPrefix(d.String(), repoName) { t.Errorf("Publish() = %v, wanted prefix %v", d, tag.Repository)