-
Notifications
You must be signed in to change notification settings - Fork 377
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
update test vendor to image-spec rc5 #241
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"schemaVersion": 2, | ||
"manifests": [ | ||
{ | ||
"mediaType": "application/vnd.oci.image.manifest.v1+json", | ||
"size": 7143, | ||
"digest": "sha256:e692418e4cbaf90ca69d05a66403747baa33ee08806650b51fab815ad7fc331f", | ||
"platform": { | ||
"architecture": "ppc64le", | ||
"os": "linux" | ||
} | ||
}, | ||
{ | ||
"mediaType": "application/vnd.oci.image.manifest.v1+json", | ||
"size": 7682, | ||
"digest": "sha256:5b0bcabd1ed22e9fb1310cf6c2dec7cdef19f0ad69efa1f392e94a4333501270", | ||
"platform": { | ||
"architecture": "amd64", | ||
"os": "linux", | ||
"os.features": [ | ||
"sse4" | ||
] | ||
} | ||
} | ||
], | ||
"annotations": { | ||
"com.example.key1": "value1", | ||
"com.example.key2": "value2" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,29 @@ | ||
{ | ||
"schemaVersion": 2, | ||
"mediaType": "application/vnd.oci.image.manifest.v1+json", | ||
"config": { | ||
"mediaType": "application/vnd.oci.image.serialization.config.v1+json", | ||
"size": 7023, | ||
"digest": "sha256:b5b2b2c507a0944348e0303114d8d93aaaa081732b86451d9bce1f432a537bc7" | ||
"schemaVersion": 2, | ||
"config": { | ||
"mediaType": "application/vnd.oci.image.config.v1+json", | ||
"size": 7023, | ||
"digest": "sha256:b5b2b2c507a0944348e0303114d8d93aaaa081732b86451d9bce1f432a537bc7" | ||
}, | ||
"layers": [ | ||
{ | ||
"mediaType": "application/vnd.oci.image.layer.v1.tar+gzip", | ||
"size": 32654, | ||
"digest": "sha256:e692418e4cbaf90ca69d05a66403747baa33ee08806650b51fab815ad7fc331f" | ||
}, | ||
"layers": [ | ||
{ | ||
"mediaType": "application/vnd.oci.image.serialization.rootfs.tar.gzip", | ||
"size": 32654, | ||
"digest": "sha256:e692418e4cbaf90ca69d05a66403747baa33ee08806650b51fab815ad7fc331f" | ||
}, | ||
{ | ||
"mediaType": "application/vnd.oci.image.serialization.rootfs.tar.gzip", | ||
"size": 16724, | ||
"digest": "sha256:3c3a4604a545cdc127456d94e421cd355bca5b528f4a9c1905b15da2eb4a4c6b" | ||
}, | ||
{ | ||
"mediaType": "application/vnd.oci.image.serialization.rootfs.tar.gzip", | ||
"size": 73109, | ||
"digest": "sha256:ec4b8955958665577945c89419d1af06b5f7636b4ac3da7f12184802ad867736" | ||
} | ||
] | ||
} | ||
{ | ||
"mediaType": "application/vnd.oci.image.layer.v1.tar+gzip", | ||
"size": 16724, | ||
"digest": "sha256:3c3a4604a545cdc127456d94e421cd355bca5b528f4a9c1905b15da2eb4a4c6b" | ||
}, | ||
{ | ||
"mediaType": "application/vnd.oci.image.layer.v1.tar+gzip", | ||
"size": 73109, | ||
"digest": "sha256:ec4b8955958665577945c89419d1af06b5f7636b4ac3da7f12184802ad867736" | ||
} | ||
], | ||
"annotations": { | ||
"com.example.key1": "value1", | ||
"com.example.key2": "value2" | ||
} | ||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,22 +6,30 @@ import ( | |
"io/ioutil" | ||
"os" | ||
"path/filepath" | ||
"runtime" | ||
|
||
"github.com/pkg/errors" | ||
|
||
"github.com/containers/image/manifest" | ||
"github.com/containers/image/types" | ||
"github.com/opencontainers/go-digest" | ||
imgspec "github.com/opencontainers/image-spec/specs-go" | ||
imgspecv1 "github.com/opencontainers/image-spec/specs-go/v1" | ||
) | ||
|
||
type ociImageDestination struct { | ||
ref ociReference | ||
ref ociReference | ||
index imgspecv1.ImageIndex | ||
} | ||
|
||
// newImageDestination returns an ImageDestination for writing to an existing directory. | ||
func newImageDestination(ref ociReference) types.ImageDestination { | ||
return &ociImageDestination{ref: ref} | ||
index := imgspecv1.ImageIndex{ | ||
Versioned: imgspec.Versioned{ | ||
SchemaVersion: 2, | ||
}, | ||
} | ||
return &ociImageDestination{ref: ref, index: index} | ||
} | ||
|
||
// Reference returns the reference used to set up this destination. Note that this should directly correspond to user's intent, | ||
|
@@ -152,10 +160,6 @@ func (d *ociImageDestination) PutManifest(m []byte) error { | |
// TODO(runcom): beaware and add support for OCI manifest list | ||
desc.MediaType = imgspecv1.MediaTypeImageManifest | ||
desc.Size = int64(len(m)) | ||
data, err := json.Marshal(desc) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
blobPath, err := d.ref.blobPath(digest) | ||
if err != nil { | ||
|
@@ -167,15 +171,19 @@ func (d *ociImageDestination) PutManifest(m []byte) error { | |
if err := ioutil.WriteFile(blobPath, m, 0644); err != nil { | ||
return err | ||
} | ||
// TODO(runcom): ugly here? | ||
if err := ioutil.WriteFile(d.ref.ociLayoutPath(), []byte(`{"imageLayoutVersion": "1.0.0"}`), 0644); err != nil { | ||
return err | ||
} | ||
descriptorPath := d.ref.descriptorPath(d.ref.tag) | ||
if err := ensureParentDirectoryExists(descriptorPath); err != nil { | ||
return err | ||
} | ||
return ioutil.WriteFile(descriptorPath, data, 0644) | ||
|
||
annotations := make(map[string]string) | ||
annotations["org.opencontainers.ref.name"] = d.ref.tag | ||
desc.Annotations = annotations | ||
d.index.Manifests = append(d.index.Manifests, imgspecv1.ManifestDescriptor{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This gives a bit of an impression that the code adds more manifests to an existing index, but we actually never read the original file and blindly overwrite it if it exists. I guess the intent is to perhaps add the “update existing index” over time? If so, this code does make enough sense; if not, and the intent is to always do a simple overwrite, the code structure could probably be a bit simpler (do nothing in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yup, the intent is to "update existing index" There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
As in, with this PR, or at some later time? Because it is not updating an existing index now. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if you call There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, true. I wasn’t considering that because we have no tools to do that (and the semantics of doing that + Anyway, that can be useful for someone who explicitly expects that |
||
Descriptor: desc, | ||
Platform: imgspecv1.Platform{ | ||
Architecture: runtime.GOARCH, | ||
OS: runtime.GOOS, | ||
}, | ||
}) | ||
|
||
return nil | ||
} | ||
|
||
func ensureDirectoryExists(path string) error { | ||
|
@@ -204,5 +212,12 @@ func (d *ociImageDestination) PutSignatures(signatures [][]byte) error { | |
// - Uploaded data MAY be visible to others before Commit() is called | ||
// - Uploaded data MAY be removed or MAY remain around if Close() is called without Commit() (i.e. rollback is allowed but not guaranteed) | ||
func (d *ociImageDestination) Commit() error { | ||
return nil | ||
if err := ioutil.WriteFile(d.ref.ociLayoutPath(), []byte(`{"imageLayoutVersion": "1.0.0"}`), 0644); err != nil { | ||
return err | ||
} | ||
indexJSON, err := json.Marshal(d.index) | ||
if err != nil { | ||
return err | ||
} | ||
return ioutil.WriteFile(d.ref.indexPath(), indexJSON, 0644) | ||
} |
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.
I vaguely remember there was an earlier conversation about this, but I can't remember the details: why is guessing that a manifest is OCI no longer applicable? Because a manifest can never be a stand-alone object with OCi without an index now? Or just because OCI decided not to include the type in the JSON?
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.
No mime type in Json anymore
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.
To expand on the above, it's because types are now implemented using descriptor types (so objects are no longer self-descriptive).
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.
Either way, this is awkward.
dirImageSource
andstorageImageSource
depend onGuessMIMEType
to work; otherwisec/i/image
assumes schema1. (Not trivially fixable.)dockerImageDestination
depends onGuessMIMEType
for settingContent-Type
on upload. (This one is probably fixable by adding an explicit parameter, and using thec/i/image
handler to get the type we are using.)Is there another heuristic we can use? e.g.
schemaVersion
==2
&&mediaType
missing? Or perhaps together withconfig.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.
fixed I think
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.
Thanks. Could the
if meta.SchemaVersion == 2
code be unified withcase 2
below?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.
done