Skip to content

Commit

Permalink
review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
imjasonh committed Aug 23, 2022
1 parent 8345419 commit d325733
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ jobs:
eval $(go env | sed -r 's/^(set )?(\w+)=("?)(.*)\3$/\2="\4"/gm')
# Check that building without push prints the tag (and sha)
KO_DOCKER_REPO="" go run ./ build --push=false ./test | grep ":latest@sha256:"
KO_DOCKER_REPO="" go run ./ build --push=false -t test ./test | grep ":test@sha256:"
KO_DOCKER_REPO="" go run ./ build --push=false -t test --tag-only ./test | grep ":test$"
Expand Down
13 changes: 10 additions & 3 deletions pkg/commands/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ func makePublisher(po *options.PublishOptions) (publish.Interface, error) {
// publishing.
if len(publishers) == 0 {
// If one or more tags are specified, use the first tag in the list
tag := "latest"
var tag string
if len(po.Tags) >= 1 {
tag = po.Tags[0]
}
Expand Down Expand Up @@ -269,14 +269,21 @@ type nopPublisher struct {

func (n nopPublisher) Publish(_ context.Context, br build.Result, s string) (name.Reference, error) {
s = strings.TrimPrefix(s, build.StrictScheme)
nm := n.namer(n.repoName, s)
if n.tagOnly {
return name.NewTag(fmt.Sprintf("%s:%s", n.namer(n.repoName, s), n.tag))
if n.tag == "" {
return nil, errors.New("must specify tag if requesting tag only")
}
return name.NewTag(fmt.Sprintf("%s:%s", nm, n.tag))
}
h, err := br.Digest()
if err != nil {
return nil, err
}
return name.NewDigest(fmt.Sprintf("%s:%s@%s", n.namer(n.repoName, s), n.tag, h))
if n.tag == "" {
return name.NewDigest(fmt.Sprintf("%s@%s", nm, h))
}
return name.NewDigest(fmt.Sprintf("%s:%s@%s", nm, n.tag, h))
}

func (n nopPublisher) Close() error { return nil }
Expand Down

0 comments on commit d325733

Please sign in to comment.