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 --fast flag to crane validate #1013

Merged
merged 3 commits into from
May 12, 2021
Merged

Conversation

jonjohnsonjr
Copy link
Collaborator

@jonjohnsonjr jonjohnsonjr commented May 10, 2021

Fixes #838

Add validate.Fast option
Add Exists to remote layers
Add Exists to layout
Add Exists to partial

Simplify some of our typechecking logic with unwrap().

Stop double-wrapping layoutImage layers.

pkg/v1/remote/image.go Outdated Show resolved Hide resolved
pkg/v1/validate/image.go Outdated Show resolved Hide resolved
@codecov-commenter
Copy link

codecov-commenter commented May 11, 2021

Codecov Report

Merging #1013 (836d7bd) into main (13fba64) will decrease coverage by 0.11%.
The diff coverage is 75.60%.

❗ Current head 836d7bd differs from pull request most recent head 17a8dbf. Consider uploading reports for the commit 17a8dbf to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1013      +/-   ##
==========================================
- Coverage   75.33%   75.22%   -0.12%     
==========================================
  Files         107      107              
  Lines        5036     5053      +17     
==========================================
+ Hits         3794     3801       +7     
- Misses        701      706       +5     
- Partials      541      546       +5     
Impacted Files Coverage Δ
pkg/v1/remote/descriptor.go 73.36% <45.45%> (-1.78%) ⬇️
pkg/v1/layout/image.go 73.33% <75.00%> (-2.28%) ⬇️
pkg/v1/partial/with.go 61.90% <88.88%> (-2.16%) ⬇️
pkg/v1/remote/image.go 79.72% <100.00%> (+0.27%) ⬆️
pkg/v1/remote/layer.go 65.51% <100.00%> (+2.55%) ⬆️
pkg/v1/remote/mount.go 76.92% <100.00%> (+0.92%) ⬆️

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 13fba64...17a8dbf. Read the comment docs.

@jonjohnsonjr jonjohnsonjr marked this pull request as ready for review May 11, 2021 17:04
@jonjohnsonjr
Copy link
Collaborator Author

jonjohnsonjr commented May 11, 2021

I'm not thrilled about this still, but the unwrap thing makes me happy.

I almost want to implement this across the board -- something like:

type Unwrapper interface {
  Unwrap() interface{}
}

This is kind of like go 1.13 error stuff -- maybe we'd want partial.Is and partial.As as well?

We could have MountableLayer implement this instead of adding pass-through methods like we're doing now:

// Descriptor retains the original descriptor from an image manifest.
// See partial.Descriptor.
func (ml *MountableLayer) Descriptor() (*v1.Descriptor, error) {
return partial.Descriptor(ml.Layer)
}

We're doing weird stuff to get partial.Descriptor to work all over the place:

$ rg -g '!*_test.go' "Descriptor\(\)"
v1/tarball/layer.go
45:func (l *layer) Descriptor() (*v1.Descriptor, error) {

v1/tarball/image.go
251:func (fl *foreignUncompressedLayer) Descriptor() (*v1.Descriptor, error) {

v1/remote/mount.go
33:func (ml *MountableLayer) Descriptor() (*v1.Descriptor, error) {
93:func (mi *mountableImage) Descriptor() (*v1.Descriptor, error) {

v1/remote/index.go
110:func (r *remoteIndex) Descriptor() (*v1.Descriptor, error) {

v1/remote/image.go
118:func (r *remoteImage) Descriptor() (*v1.Descriptor, error) {
220:func (rl *remoteImageLayer) Descriptor() (*v1.Descriptor, error) {

v1/partial/with.go
284:    Descriptor() (*v1.Descriptor, error)
301:            return wd.Descriptor()
306:            return wd.Descriptor()

This might be a nice interim until we can rip out the partial stuff altogether?

@@ -221,6 +221,16 @@ func (rl *remoteImageLayer) Descriptor() (*v1.Descriptor, error) {
return partial.BlobDescriptor(rl, rl.digest)
}

// See partial.Exists.
func (rl *remoteImageLayer) Exists() (bool, error) {
resp, err := rl.ri.headBlob(rl.digest)
Copy link
Collaborator

Choose a reason for hiding this comment

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

If the method returns (bool, error) I would expect there to be some possibility of returning false, nil -- otherwise, the bool is just equivalent err != nil, and doesn't provide any other information.

Could this return false, nil if headBlob returns a 404? (Indicating that it successfully determined that the blob doesn't exist)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You caught me being lazy, look again.

Add validate.Fast option
Add Exists to remote layers
Add Exists to layout
Add Exists to partial

Simplify some of our typechecking logic with unwrap().

Stop double-wrapping layoutImage layers.
@jonjohnsonjr jonjohnsonjr merged commit 4c244d6 into google:main May 12, 2021
@jonjohnsonjr jonjohnsonjr deleted the validate-fast branch May 12, 2021 18:14
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.

how do I check if a layout contains all of the blobs?
4 participants