diff --git a/pkg/commands/resolver.go b/pkg/commands/resolver.go index 9f47d3e220..2b341c7d62 100644 --- a/pkg/commands/resolver.go +++ b/pkg/commands/resolver.go @@ -172,10 +172,21 @@ func makePublisher(po *options.PublishOptions) (publish.Interface, error) { innerPublisher, err := func() (publish.Interface, error) { repoName := po.DockerRepo namer := options.MakeNamer(po) - if strings.HasPrefix(repoName, publish.LocalDomain) || po.Local { + // Default LocalDomain if unset. + if po.LocalDomain == "" { + po.LocalDomain = publish.LocalDomain + } + // If repoName is unset with --local, default it to the local domain. + if po.Local && repoName == "" { + repoName = po.LocalDomain + } + // When in doubt, if repoName is under the local domain, default to --local. + po.Local = strings.HasPrefix(repoName, po.LocalDomain) + if po.Local { // TODO(jonjohnsonjr): I'm assuming that nobody will // use local with other publishers, but that might // not be true. + po.LocalDomain = repoName return publish.NewDaemon(namer, po.Tags, publish.WithDockerClient(po.DockerClient), publish.WithLocalDomain(po.LocalDomain), diff --git a/pkg/commands/resolver_test.go b/pkg/commands/resolver_test.go index 21d2d5d610..7031f0669c 100644 --- a/pkg/commands/resolver_test.go +++ b/pkg/commands/resolver_test.go @@ -279,6 +279,15 @@ func TestNewPublisherCanPublish(t *testing.T) { shouldError: true, wantError: errImageLoad, }, + { + description: "bare with local domain and repo", + wantImageName: strings.ToLower(fmt.Sprintf("%s/foo", dockerRepo)), + po: &options.PublishOptions{ + DockerRepo: dockerRepo + "/foo", + Local: true, + Bare: true, + }, + }, } for _, test := range tests { t.Run(test.description, func(t *testing.T) {