Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow plain registries as KO_DOCKER_REPO #94

Merged
merged 1 commit into from
Oct 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions pkg/commands/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,10 @@ func makePublisher(no *options.NameOptions, lo *options.LocalOptions, ta *option
if repoName == "" {
return nil, errors.New("KO_DOCKER_REPO environment variable is unset")
}
_, err := name.NewRepository(repoName)
if err != nil {
return nil, fmt.Errorf("failed to parse environment variable KO_DOCKER_REPO=%q as repository: %v", repoName, err)
if _, err := name.NewRegistry(repoName); err != nil {
if _, err := name.NewRepository(repoName); err != nil {
return nil, fmt.Errorf("failed to parse environment variable KO_DOCKER_REPO=%q as repository: %v", repoName, err)
}
}

return publish.NewDefault(repoName,
Expand Down
11 changes: 8 additions & 3 deletions pkg/publish/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,16 @@ func WithAuthFromKeychain(keys authn.Keychain) Option {
// means that docker.io/mattmoor actually gets interpreted as
// docker.io/library/mattmoor, which gets tricky when we start
// appending things to it in the publisher.
repo, err := name.NewRepository(i.base)
reg, err := name.NewRegistry(i.base)
if err != nil {
return err
// Workaround for localhost:5000 as KO_DOCKER_REPO.
repo, err := name.NewRepository(i.base)
if err != nil {
return err
}
reg = repo.Registry
}
auth, err := keys.Resolve(repo.Registry)
auth, err := keys.Resolve(reg)
if err != nil {
return err
}
Expand Down