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 authored and imjasonh committed Mar 20, 2024
1 parent 7067ad2 commit 5ce94b9
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
Expand Up @@ -196,7 +196,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
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 5ce94b9

Please sign in to comment.