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

Add partial.ImageByPlatform helper #797

Closed
wants to merge 1 commit into from

Conversation

imjasonh
Copy link
Collaborator

@imjasonh imjasonh commented Oct 23, 2020

This is used by ko now in a couple places, and it seems like a useful
helper to provide in general.

Reuse this helper in pkg/v1/remote/

@codecov-io
Copy link

codecov-io commented Oct 23, 2020

Codecov Report

Merging #797 into master will increase coverage by 0.02%.
The diff coverage is 85.29%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #797      +/-   ##
==========================================
+ Coverage   74.72%   74.75%   +0.02%     
==========================================
  Files         103      104       +1     
  Lines        4313     4313              
==========================================
+ Hits         3223     3224       +1     
  Misses        612      612              
+ Partials      478      477       -1     
Impacted Files Coverage Δ
pkg/v1/partial/index.go 82.75% <82.75%> (ø)
pkg/v1/remote/descriptor.go 74.85% <100.00%> (+0.46%) ⬆️
pkg/v1/remote/index.go 86.27% <100.00%> (-0.48%) ⬇️
pkg/v1/cache/fs.go 70.00% <0.00%> (+3.33%) ⬆️

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 051a6c0...a8e1d56. Read the comment docs.

pkg/v1/partial/index.go Outdated Show resolved Hide resolved

// ImageByArch returns the v1.Image belonging to the v1.ImageIndex with the
// matching OS and Architecture.
func ImageByArch(w WithRawIndexManifest, os, arch string) (v1.Image, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd almost rather have this return a WithRawManifest or something given that, in theory, an index could have a child index with a platform field, but I understand that it would make the calling code more cumbersome.

Since child image is by far the common case, I'm fine merging this, but I'm not 100% happy about it :)

pkg/v1/partial/index.go Show resolved Hide resolved
@imjasonh imjasonh force-pushed the image-by-arch branch 2 times, most recently from 78e4488 to 6979a89 Compare October 29, 2020 00:45
@imjasonh imjasonh changed the title Add partial.ImageByArch helper Add partial.ImageByPlatform helper Oct 29, 2020
This is used by ko now in a couple places, and it seems like a useful
helper to provide in general.

Reuse this helper in pkg/v1/remote/

// WithRawIndexManifest defines the subset of v1.ImageIndex used by ImageByArch.
type WithRawIndexManifest interface {
RawManifest() ([]byte, error)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm actually concerned that this is too general because a v1.Image that also implements Image(Hash) will satisfy this, but will not work at all because v1.Image's descriptors are under Layers. Should we just have ImageByPlatform take a v1.ImageIndex instead?

@imjasonh
Copy link
Collaborator Author

Closing in favor of #823

@imjasonh imjasonh closed this Nov 12, 2020
@deitch deitch mentioned this pull request Nov 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants