Skip to content

Commit

Permalink
Fix kind image names with --bare
Browse files Browse the repository at this point in the history
Make the functionality match between:
KO_DOCKER_REPO=ko.local/my-image ko build --bare

And:
KO_DOCKER_REPO=kind.local/my-image ko build --bare

As it stands, `--bare` is broken with `kind.local/` as it just gets
`kind.local` as the image name, and then it fails to tag because the
registry is missing.
  • Loading branch information
aidy committed Apr 27, 2023
1 parent 7c72ccf commit 7774527
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pkg/commands/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ func makePublisher(po *options.PublishOptions) (publish.Interface, error) {
)
}
if strings.HasPrefix(repoName, publish.KindDomain) {
return publish.NewKindPublisher(namer, po.Tags), nil
return publish.NewKindPublisher(repoName, namer, po.Tags), nil
}

if repoName == "" && po.Push {
Expand Down
8 changes: 5 additions & 3 deletions pkg/publish/kind.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,15 @@ const (
)

type kindPublisher struct {
base string
namer Namer
tags []string
}

// NewKindPublisher returns a new publish.Interface that loads images into kind nodes.
func NewKindPublisher(namer Namer, tags []string) Interface {
func NewKindPublisher(base string, namer Namer, tags []string) Interface {
return &kindPublisher{
base: base,
namer: namer,
tags: tags,
}
Expand Down Expand Up @@ -96,7 +98,7 @@ func (t *kindPublisher) Publish(ctx context.Context, br build.Result, s string)
return nil, err
}

digestTag, err := name.NewTag(fmt.Sprintf("%s:%s", t.namer(KindDomain, s), h.Hex))
digestTag, err := name.NewTag(fmt.Sprintf("%s:%s", t.namer(t.base, s), h.Hex))
if err != nil {
return nil, err
}
Expand All @@ -109,7 +111,7 @@ func (t *kindPublisher) Publish(ctx context.Context, br build.Result, s string)

for _, tagName := range t.tags {
log.Printf("Adding tag %v", tagName)
tag, err := name.NewTag(fmt.Sprintf("%s:%s", t.namer(KindDomain, s), tagName))
tag, err := name.NewTag(fmt.Sprintf("%s:%s", t.namer(t.base, s), tagName))
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 7774527

Please sign in to comment.