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

Support ko build ./... #644

Closed
wants to merge 6 commits into from
Closed

Conversation

imjasonh
Copy link
Member

@imjasonh imjasonh commented Mar 11, 2022

This changes ko build to interpret an importpath string that ends in
"/..." by running go list and parsing its output to find package mains matched by that wildcard.

Since ko build already supports passing multiple paths, this
additively collects uniq matched importpaths, so this works, and
produces three images for the three package mains in this repo:

ko build ./... ./cmd/... ./

Matched paths are still checked if they're package main, so this
doesn't work:

ko build ./... ./pkg/build

(because the explicit pkg/build isn't package main)

This also doesn't work, because the wildcard importpath doesn't match any package mains:

ko build ./pkg/...

This does work, because the set of wildcard importpaths taken together matches at least one package main:

ko build ./cmd/... ./pkg/...

Fixes #643
Fixes #273

This changes `ko build` to interpret an importpath string that ends in
"/..." by running `go list` and parsing its output to find `package
main`s matched by that wildcard.

Since `ko build` already supports passing multiple paths, this
additively collects uniq matched importpaths, so this works, and
produces three images for the three `package main`s in this repo:

```
ko build ./... ./cmd/... ./
```

Matched paths are still checked if they're `package main`, so this
doesn't work:

```
ko build ./... ./pkg/build
```

(because `pkg/build` isn't `package main`)
@imjasonh imjasonh requested a review from mattmoor March 11, 2022 14:43
@codecov-commenter
Copy link

codecov-commenter commented Mar 11, 2022

Codecov Report

Merging #644 (bb7530e) into main (204fbc9) will decrease coverage by 0.28%.
The diff coverage is 0.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #644      +/-   ##
==========================================
- Coverage   51.92%   51.64%   -0.29%     
==========================================
  Files          44       44              
  Lines        3291     3309      +18     
==========================================
  Hits         1709     1709              
- Misses       1371     1389      +18     
  Partials      211      211              
Impacted Files Coverage Δ
pkg/commands/build.go 47.50% <0.00%> (-13.80%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 204fbc9...bb7530e. Read the comment docs.

Copy link
Collaborator

@mattmoor mattmoor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well that seems nice and easy 👍

@imjasonh
Copy link
Member Author

Well that seems nice and easy 👍

Integration tests fail while I'm using packages.Load instead of shelling out to go list -- I'll either figure it out, or just switch to go list until I figure it out.

@github-actions
Copy link

This Pull Request is stale because it has been open for 90 days with
no activity. It will automatically close after 30 more days of
inactivity. Keep fresh with the 'lifecycle/frozen' label.

@imjasonh
Copy link
Member Author

imjasonh commented Jul 9, 2022

@github-actions
Copy link

github-actions bot commented Oct 9, 2022

This Pull Request is stale because it has been open for 90 days with
no activity. It will automatically close after 30 more days of
inactivity. Keep fresh with the 'lifecycle/frozen' label.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Idea: build all images defined in .ko.yaml ko publish ./...
3 participants