diff --git a/pkg/skaffold/build/ko/publisher.go b/pkg/skaffold/build/ko/publisher.go index a56f8bde0c1..b0636798c5a 100644 --- a/pkg/skaffold/build/ko/publisher.go +++ b/pkg/skaffold/build/ko/publisher.go @@ -46,6 +46,10 @@ func publishOptions(ref string, pushImages bool, dockerClient daemon.Client, ins return nil, err } imageNameWithoutTag := imageRef.Context().Name() + localDomain := "" + if !pushImages { + localDomain = imageNameWithoutTag + } return &options.PublishOptions{ Bare: true, @@ -53,7 +57,7 @@ func publishOptions(ref string, pushImages bool, dockerClient daemon.Client, ins DockerRepo: imageNameWithoutTag, InsecureRegistry: useInsecureRegistry(imageNameWithoutTag, insecureRegistries), Local: !pushImages, - LocalDomain: imageNameWithoutTag, + LocalDomain: localDomain, Push: pushImages, Tags: []string{imageRef.Identifier()}, UserAgent: version.UserAgentWithClient(), diff --git a/pkg/skaffold/build/ko/publisher_test.go b/pkg/skaffold/build/ko/publisher_test.go index cf3298040c4..d203af42331 100644 --- a/pkg/skaffold/build/ko/publisher_test.go +++ b/pkg/skaffold/build/ko/publisher_test.go @@ -84,7 +84,10 @@ func TestPublishOptions(t *testing.T) { t.Errorf("wanted InsecureRegistry (%v), got (%v)", test.wantInsecureRegistry, po.InsecureRegistry) } if !test.pushImages && po.LocalDomain != test.repo { - t.Errorf("wanted LocalDomain (%q), got (%q)", test.repo, po.DockerRepo) + t.Errorf("wanted LocalDomain (%q), got (%q)", test.repo, po.LocalDomain) + } + if test.pushImages && po.LocalDomain != "" { + t.Errorf("wanted zero value for LocalDomain, got (%q)", po.LocalDomain) } if test.pushImages == po.Local { t.Errorf("Local (%v) should be the inverse of pushImages (%v)", po.Local, test.pushImages)