Conversation
| if err != nil { | ||
| return nil, "", err | ||
| } | ||
| // TODO(runcom): we should hide this type from the pkg API |
There was a problem hiding this comment.
This will be eventually just an anonymous struct with methods from the interface to be complain with the return interface arg (or at least I'd love to do so)
There was a problem hiding this comment.
The ImageManifest returned by dirImageSource needs to understand the manifest contents just as well as the dockerImageSource implementation.
I.e. I think the “download a manifest” and “parse and understand a manifest” code should be separate, with the ImageSource abstraction serving as the border.
0af3fa0 to
8b5a1a6
Compare
docker/docker_image_src.go
Outdated
|
|
||
| func (i *dockerImage) getTags() ([]string, error) { | ||
| func (s *dockerImageSource) getTags() ([]string, error) { | ||
| // FIXME? Breaking the abstraction. |
There was a problem hiding this comment.
I don't remember why this is here (@mtrmac ?)
There was a problem hiding this comment.
"breaking the abstraction” refers to dockerImage directly using members of i.src = dockerImageSource. That would not be applicable any longer if the method were moved to dockerImageSource.
dd0342b to
eaa4454
Compare
|
I am not sure about the direction of this; I was thinking of Basically we need to very carefully think about which attributes are common to all storage mechanisms, and which are specific to Docker Registry / OCI bundles / ostree subtrees / … . (It might well turn out that the dumb storage abstraction is simply unworkable. But if so, we should not be using the “manifest” term referring to v2s[12] config+layer lists to mean “any container image in any format whatsoever”.) |
|
@mtrmac I don't still know if Image[Source|Destination] will be good. However this PR is simply moving files around (and just adapting some code). skopeo was born to just fetch and display manifest from registries at the beginning. However, I think it would be good trying to abstract a common template for manifests (as originally thought upstream also).
when referring to manifest I'm referring to |
|
I'm thinking for instance, that the storage layers you added (source|destination) can be very well suited inside a top level object exposed in the API (thinking out loud) |
cmd/skopeo/copy.go
Outdated
| } | ||
| signBy := context.String("sign-by") | ||
|
|
||
| // TODO(runcom): unused digest??? Miloslav? |
There was a problem hiding this comment.
(Strictly speaking it is printed to stdout, so not unused…)
The digest is there only because dockerImage.retrieveRawManifest was using it to eventually store it into a DockerImageManifest, and skopeo inspect is printing it to stdout. I did not look further into whether that should happen at all (though why print the unverified digest instead computing a fresh one, now that I look at it?) and simply preserved the original data flow.
There was a problem hiding this comment.
Actually I don’t think there is a good reason for copy to write this to stdout at all. #53 .
I understand your concerns here though, let me rework this again so that those 2 interfaces just give out a blob |
I would agree with a simple move in a jiffy. The “adapting some code” here is changing the philosopy, and that will require more thought. You may well be right but I’d like to think about it a bit more. |
This is probably the root of the disconnect; I am thinking about the Docker Registry manifest concept, which does not know that much about containers or tags or anything. |
Yes, I am thinking along the same lines. If we separate the distribution aspect (the func ParseDockerImage(types.ImageSource) (types.Image, error)which would internally download the manifest blob, and then convert it into something much more useful to actual end users (e.g. list of layers, labels, configuration extracted from the manifest into nice fields, a method to convert that into a runc setup, whatever). (Yes, that is quite similar to the existing ( |
|
One other thing while you are doing this rework could you remove "docker" wherever possible and use oci, if applicable. Since we will be pulling and pushing oci images as well as docker images. |
| // TODO(runcom): unused version param for now, default to docker v2-1 | ||
| m, err := i.getSchema1Manifest() | ||
| if err != nil { | ||
| if err := i.retrieveRawManifest(); err != nil { |
There was a problem hiding this comment.
BTW (independent of the rest):
If all retrieveRawManifest does is store the values of i.src.GetManifest, wouldn’t it be simpler to call it directly here, and remove the retrieveRawManifest function entirely?
I suppose we might want caching… but if so, perhaps it should be somehow universal. Make it a contract of ImageSource that data is cached, or add a CachingImageSource?
There was a problem hiding this comment.
you're totally right - I just overlooked thinking about this but it does smell a lot - thanks for the suggestion
At the moment, this implements Docker Registry (for which there is no corresponding OCI specification) and Registry V2 “Schema 1” manifests (likewise; OCI standardizes “Schema 2”). The top-level types are named generically, e.g. Other than that, throughout the code we refer to
|
… and then there is the |
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
|
closing this in favor of what @mtrmac is doing (though the conversation was interesting) |
@mtrmac PTAL (I've also added some TODO)
This is just another small steps in defining a good API for sub pkgs (which could be later used by other pkgs, i.e. k8s)
Eventually I'd love to remove
docker/docker_image.goand integrate relevand code either in img src or img dest. (@mtrmac please confirm this is your view also 😄 )The major change (other then moving files around) is that I've strongly types
GetManifest()to return an interface (with some methods just added) so it will work across implementation.Again, this is still a WIP but I would like to have this merged and tested as we going forward with this (and also avoid having to review 10k LOC PRs :) :) :))
This code compiles right but I'd love if you could test it out (specifically for openshift related stuff and signing)
Signed-off-by: Antonio Murdaca runcom@redhat.com