make the image-tool work with -rc5#144
Conversation
ad644c4 to
29d31ee
Compare
image/descriptor.go
Outdated
| } | ||
|
|
||
| // Index implementation | ||
| type Index v1.ImageIndex |
There was a problem hiding this comment.
This is not really needed. Is there a particular reason to make a local type for this struct? I could end up complicating golang type assertions
There was a problem hiding this comment.
I need this struct to carry the contents of index.json.
There was a problem hiding this comment.
But why not just use v1.ImageIndex? You're not defining any methods so there should be no need to add this extra level of type indirection.
image/descriptor.go
Outdated
|
|
||
| var d descriptor | ||
| if err := json.NewDecoder(r).Decode(&d); err != nil { | ||
| buf, err := ioutil.ReadAll(r) |
There was a problem hiding this comment.
doing a .ReadAll is a bit more expensive, where the previous version is a streaming decoder. I'd prefer a streaming decoder.
image/descriptor.go
Outdated
| } | ||
|
|
||
| if err := json.NewDecoder(r).Decode(&d); err != nil { | ||
| buf, err := ioutil.ReadAll(r) |
b8c8494 to
ea52a59
Compare
|
@cyphar PTAL (need this for skopeo tests in containers/skopeo#313) |
We need opencontainers/image-tools#144 first Signed-off-by: Antonio Murdaca <runcom@redhat.com>
We need opencontainers/image-tools#144 first Signed-off-by: Antonio Murdaca <runcom@redhat.com>
We need opencontainers/image-tools#144 first Signed-off-by: Antonio Murdaca <runcom@redhat.com>
|
What do you think of this PR? Some of the improvements in |
image/descriptor.go
Outdated
| d.MediaType = index.Manifests[i].Descriptor.MediaType | ||
| d.Digest = string(index.Manifests[i].Descriptor.Digest) | ||
| d.Size = index.Manifests[i].Descriptor.Size | ||
| refs[index.Manifests[i].Descriptor.Annotations["org.opencontainers.ref.name"]] = &d |
There was a problem hiding this comment.
This will completely flatten the set of references (silently ignoring duplicates). I've spent quite a while trying to come up with a sane API for umoci and I think I've decided the only way to implement this is to remove the concept of a reference in the lower-level libraries and have it as a higher-level construct.
In umoci this split was quite easy to do with oci/cas vs oci/casext which adds implementation-agnostic extensions to oci/cas. Maybe that's something you can do so you can remove the old concepts of a reference being a simple mapping.
There was a problem hiding this comment.
Why are we making this so complicated? Just return a slice of descriptors.
There was a problem hiding this comment.
@stevvooe ... because first-class references aren't a property of the underlying storage anymore ...
Whatever, I'm not going to get into another argument over this.
There was a problem hiding this comment.
I try to use type descriptor v1.Descriptor instead of descriptor, but the following error occurs:
/tmp/go-build341304265/github.com/opencontainers/image-tools/image/_test/_obj_test/descriptor.go:47:cannot use d.Digest (type digest.Digest) as type string in argument to strings.SplitN
/tmp/go-build341304265/github.com/opencontainers/image-tools/image/_test/_obj_test/descriptor.go:81: cannot use &index.Manifests[i].Descriptor (type *v1.Descriptor) as type *descriptor in assignment
What I am using is what I can think of.As for the kind of ideas you say I want to do, but can not solve the problem after the amendment.
There was a problem hiding this comment.
Whatever, I'm not going to get into another argument over this.
Please avoid the passive aggressive tone.
There was a problem hiding this comment.
@q384566678 You need to convert to string: dgst.String() should do the trick. However, it also looks like this local descriptor type is no longer needed.
There was a problem hiding this comment.
@stevvooe Sorry to disturb, I have solved other problems, only the problem can not be resolved.
descriptor.go:64: cannot use index.Manifests[i].Descriptor (type v1.Descriptor) as type descriptor in assignment
Or is there a problem with my method. Can we discuss this question? If can't solve the problem I think I still use the method in ea52a59. ( I think this method is feasible.)
I hope to also try to promote the development of image-tool, but sometimes some technical problems need your help.Thanks.
There was a problem hiding this comment.
@q384566678 The problem is that there is a local type descriptor and a common type, v1.Descriptor. You either need to convert the types or just use the v1.Descriptor type.
4b1b706 to
06d86d2
Compare
Signed-off-by: zhouhao <zhouhao@cn.fujitsu.com>
|
@opencontainers/image-tools-maintainers PTAL |
|
@opencontainers/image-tools-maintainers I think this can be merged.PTAL, thanks. |
image/descriptor.go
Outdated
| Digest string `json:"digest"` | ||
| Size int64 `json:"size"` | ||
| } | ||
| type descriptor v1.Descriptor |
There was a problem hiding this comment.
Why make this type definition? Just use the type.
There was a problem hiding this comment.
Remove the type def please.
There was a problem hiding this comment.
updated,I used to define this type because of this function,
func (d *descriptor) validate(w walker, mts []string) error {
and now I changed it to
func ValidateDescriptor(d *v1.Descriptor, w walker, mts []string) error {
PTAL
image/descriptor.go
Outdated
| } | ||
| type descriptor v1.Descriptor | ||
|
|
||
| func (d *descriptor) algo() string { |
There was a problem hiding this comment.
Lost this code: this just go-digest to do this properly.
|
@q384566678 Rather than defining a new descriptor type, just use the existing one. |
|
@stevvooe
If you want to use the original definition as you say, you can only assign each structure separately in the original way:
|
|
@q384566678 The type definition is not needed. Remove the extra type and it will work. You may need to update a few to make it work. |
fdb2505 to
ba46dee
Compare
image/descriptor.go
Outdated
|
|
||
| func (d *descriptor) validate(w walker, mts []string) error { | ||
| //ValidateDescriptor validate descriptor type | ||
| func ValidateDescriptor(d *v1.Descriptor, w walker, mts []string) error { |
There was a problem hiding this comment.
No need to export this. It is use unexported interfaces, so it is pointless, anyways.
image/descriptor.go
Outdated
| } | ||
|
|
||
| parsed, err := digest.Parse(d.Digest) | ||
| parsed, err := digest.Parse(string(d.Digest)) |
There was a problem hiding this comment.
No need to parse a digest that is already a digest. Just call d.Digest.Validate().
image/image_test.go
Outdated
| } | ||
|
|
||
| parsed, err := digest.Parse(desc.Digest) | ||
| parsed, err := digest.Parse(string(desc.Digest)) |
There was a problem hiding this comment.
updated, PTAL.
ping @opencontainers/image-tools-maintainers
Signed-off-by: zhouhao <zhouhao@cn.fujitsu.com>
|
@xiekeyang @coolljt0725 @vbatts PTAL. |
|
@q384566678 Can you answer this question please?
|
|
👍 |
This is a #121 follow-up PR, make the image-tool work with -rc5. Sorry so late update.
Signed-off-by: zhouhao zhouhao@cn.fujitsu.com