-
Notifications
You must be signed in to change notification settings - Fork 83
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
make the image-tool work with -rc5 #144
Conversation
ad644c4
to
29d31ee
Compare
image/descriptor.go
Outdated
@@ -48,19 +50,36 @@ func (d *descriptor) hash() string { | |||
return pts[1] | |||
} | |||
|
|||
// Index implementation | |||
type Index v1.ImageIndex |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need this struct to carry the contents of index.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.
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.
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.
Oh I see, updated, thanks.
image/descriptor.go
Outdated
return nil | ||
} | ||
|
||
var d descriptor | ||
if err := json.NewDecoder(r).Decode(&d); err != nil { | ||
buf, err := ioutil.ReadAll(r) |
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.
doing a .ReadAll
is a bit more expensive, where the previous version is a streaming decoder. I'd prefer a streaming decoder.
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.
updated. PTAL.
image/descriptor.go
Outdated
return nil | ||
} | ||
|
||
if err := json.NewDecoder(r).Decode(&d); err != nil { | ||
buf, err := ioutil.ReadAll(r) |
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.
same
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 <[email protected]>
We need opencontainers/image-tools#144 first Signed-off-by: Antonio Murdaca <[email protected]>
We need opencontainers/image-tools#144 first Signed-off-by: Antonio Murdaca <[email protected]>
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we making this so complicated? Just return a slice of descriptors.
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.
yeah, and just append 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.
@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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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 <[email protected]>
@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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why make this type definition? Just use the type.
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.
Remove the type def please.
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.
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
Digest string `json:"digest"` | ||
Size int64 `json:"size"` | ||
} | ||
type descriptor v1.Descriptor | ||
|
||
func (d *descriptor) algo() string { |
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.
Lost this code: this just go-digest to do this properly.
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.
updated.
@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
case errEOW: | ||
return &d, nil | ||
default: | ||
return nil, err | ||
} | ||
} | ||
|
||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to export this. It is use unexported interfaces, so it is pointless, anyways.
image/descriptor.go
Outdated
@@ -105,7 +96,7 @@ func (d *descriptor) validate(w walker, mts []string) error { | |||
return fmt.Errorf("invalid descriptor MediaType %q", d.MediaType) | |||
} | |||
|
|||
parsed, err := digest.Parse(d.Digest) | |||
parsed, err := digest.Parse(string(d.Digest)) |
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 need to parse a digest that is already a digest. Just call d.Digest.Validate()
.
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.
updated, PTAL, thanks.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
desc.Digest.Validate()
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.
updated, PTAL.
ping @opencontainers/image-tools-maintainers
Signed-off-by: zhouhao <[email protected]>
@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 [email protected]