Skip to content

Make types.Image Docker-independent, add docker.GenericImageFromSource#79

Merged
mtrmac merged 7 commits intocontainers:masterfrom
mtrmac:image-from-imagesource
May 30, 2016
Merged

Make types.Image Docker-independent, add docker.GenericImageFromSource#79
mtrmac merged 7 commits intocontainers:masterfrom
mtrmac:image-from-imagesource

Conversation

@mtrmac
Copy link
Contributor

@mtrmac mtrmac commented May 28, 2016

Following up on the discussions in #52 and #58 , this allows using types.Image for non-Docker types.ImageSource backends, instead moving the Docker-specific knowledge into docker.Image and the skopeo inspect implementation.

This will be useful for policy evaluation unit tests, by allowing testing against a dir:… types.Image without having to construct testing-only mocks and reimplement Image functionality like MatchesManifestDigest (#75) in the mocks.

As is, this is not a complete API cleanup (e.g. having the generic Image constructor as docker.GenericImageFromSource is clearly not the right thing to do) but it does move us closer to the desired end state, at least in the implementation if not in the external API.

See the individual commits for detailed comments.

mtrmac added 7 commits May 28, 2016 02:04
We abort on failure to get the data anyway, so there is no need to use
temporaries to avoid modifying outputData on failure.

This is not a simplification yet, but handling optional (e.g.
Docker-specific) data this way will be simpler, and handling
non-optional data the same way will be more consistent.
This does not change the code at all, only moving things around now.
This is the only Docker-specific aspect of types.Image.Inspect.

This does not change behavior; plausibly we might want to replace the
Name value in (skopeo inspect) by something else which is not dependent
on Docker, but that can be a separate work later.

Adds a FIXME? in docker_image.go for consistency with
dockerImage.GetRepositoryTags, both will be removed later in the
patchset.
The code not dependent on specifics of DockerImageSource now lives in
docker.genericImage; the rest directly in docker.Image.

docker.Image remains the only implementation of types.Image at this
point, but that will change.
This finally makes genericImage Docker-independent.

(dockerImage is still the only implementation of types.Image.)
The remaining uses of the dependencies, in (skopeo inspect), now check
whether their types.Image is a docker.Image and call the docker.Image
functions directly.

This does not change behavior for Docker images.

For non-Docker images (which can't happen yet), the Name field is
removed; RepoTags remain and are reported as empty, because using
json:",omitempty" would also omit an empty list for Docker images.
This is not expected to be that useful in production; for now it serves
as a demonstration of the concept, and it allows (skopeo inspect) to be
clumsily used as parser of stand-alone manifests (by creating a dir:
structure with that manifest).

(skopeo layers) support follows naturally, but is even less useful.
@runcom
Copy link
Member

runcom commented May 30, 2016

👍 fine to me for now, feel free to merge it!

@mtrmac mtrmac merged commit 0d95328 into containers:master May 30, 2016
@mtrmac mtrmac deleted the image-from-imagesource branch May 30, 2016 15:35
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 10, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants