Skip to content

Commit

Permalink
Fix -P with passing ko:// through. (#163)
Browse files Browse the repository at this point in the history
Turns out I broke this.  Thanks to @bobcatfish for reporting the issue.

With this change:
```
ko resolve -Pf cmd/ko/test/test.yaml > /dev/null
2020/05/04 08:44:35 Using base gcr.io/distroless/static:nonroot for github.com/google/ko/cmd/ko/test
2020/05/04 08:44:36 Building github.com/google/ko/cmd/ko/test
2020/05/04 08:44:37 Publishing gcr.io/mattmoor-knative/github.com/google/ko/cmd/ko/test:latest
2020/05/04 08:44:39 Published gcr.io/mattmoor-knative/github.com/google/ko/cmd/ko/test@sha256:ee655510172b429dbce619fc69677621d71cb824cbbf2a21746d700127257ec4
```

I can cut v0.5.1 once this lands.
  • Loading branch information
mattmoor authored May 4, 2020
1 parent d45c527 commit ea2beac
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 2 additions & 0 deletions pkg/publish/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down Expand Up @@ -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)

Expand Down
9 changes: 5 additions & 4 deletions pkg/publish/default_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit ea2beac

Please sign in to comment.