-
Notifications
You must be signed in to change notification settings - Fork 549
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
Implement index mutation #520
Conversation
Codecov Report
@@ Coverage Diff @@
## master #520 +/- ##
==========================================
+ Coverage 73.1% 73.19% +0.08%
==========================================
Files 92 94 +2
Lines 3938 4006 +68
==========================================
+ Hits 2879 2932 +53
- Misses 696 703 +7
- Partials 363 371 +8
Continue to review full report at Codecov.
|
An alternative to having two methods is something like: type Appendable interface {
RawManifest() ([]byte, error)
MediaType() (types.MediaType, error)
}
type IndexAddendum struct {
Add v1.ImageIndex
v1.Descriptor
}
func AppendManifest(idx v1.ImageIndex, adds ...IndexAddenedum) v1.ImageIndex {
switch v := i.(type) {
case v1.ImageIndex:
// add to indexMap
case v1.Image:
// add to imageMap
case v1.Layer:
// TODO: how can we do this, actually?
default:
// log warning for unexpected addendum
}
// add descriptor to manifest
} We could also do type checking against something that just implements I suppose we could also append anything that implements: type Appendable interface {
Size() (int64, error)
MediaType() (types.MediaType, error)
Digest() (v1.Hash, error)
} Neither |
191b8ac
to
cf0ee5c
Compare
@@ -75,7 +76,7 @@ func validateChildren(idx v1.ImageIndex) error { | |||
errs = append(errs, fmt.Sprintf("failed to validate image MediaType[%d](%s): %v", i, desc.Digest, err)) | |||
} | |||
default: | |||
return fmt.Errorf("todo: validate index Blob()") | |||
logs.Warn.Printf("Unexpected manifest: %s", desc.MediaType) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to return here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to add a Blob
method to v1.ImageIndex
if I want to fix that. I can send a PR for that as well, but as it is this will break our tests if I return an error. I'm pretty sure I do want to add Blob
to that interface, but I'd like someone to tell me it's a good idea first :)
0794b69
to
d056be0
Compare
Add an
AppendManifests
function that adds entries to themanifests
clause of an index.Fixes #474