Skip to content

Conversation

@mtrmac
Copy link
Collaborator

@mtrmac mtrmac commented Jul 16, 2016

This is split from #33 to make the review process a bit less overwhelming.

Introduces types.ImageTransport and types.ImageReference, and reorganizes the code to work with ImageReference for image identity.

Does not change anything about the behavior, except for the last commit which takes advantage of the ability to get an ImageReference from a types.Image to improve some error messages.

See individual commits for detailed description and rationale.

mtrmac added 7 commits July 16, 2016 05:08
This minimizes transport-specific knowledge in image name parsing
(as in cmd/skopeo/utils.go) and allows separation of reference parsing
and their use.

Existing public NewImage... API has been removed; callers are expected
to use any of
* types.ImageTransport.ParseReference().NewImage...
  (if they have a general string)
* transportpackage.ParseReference().NewImage...
  (if they have a transport-specific string)
* transportpackage.NewReference().NewImage...
  (if they have transport-specific raw values)

This usually adds an extra error checking step for the
ParseReference/NewReference call compared to the previous code; this is
considered not a big loss, especially because reporting “the reference
is invalid” and “the reference looks valid but connecting/using it
failed” as distinct failure modes seems quite useful for users.

The references are currently one-way (you can get a types.Image* from an
ImageReference, but not the other way around); that will be fixed soon.

Signed-off-by: Miloslav Trmač <[email protected]>
This will consolidate Docker reference usage to all go through
types.ImageReference.

No users yet, will be migrated imminently.

Signed-off-by: Miloslav Trmač <[email protected]>
This also removes the error return value, only supporting nil
to indicate "Docker references not supported"; other kinds of
errors should have been handled when initially parsing or
creating the reference.

Signed-off-by: Miloslav Trmač <[email protected]>
This package maintains the list of all known transports, and provides
helpers to convert between strings and types.ImageReference ; this
should be the primary entrypoint for callers who want to just provide an
UI without dealing with the underlying ImageReference structures or
specific transports.

This makes the skopeo/cmd/skopeo/utils.go transport:transport-specific
string format a containers/image -defined feature.

This would fit nicely into containers/image/image, but the individual
transports depend on that package for creating a types.Image instance,
so we would have a circular dependency.  And containers/image/signature
will need to depend on the list of transports maintained by this, so
maintaining it at the top containers/image level would be a bad fit as
well.

So, sadly, another small subpackage.

Though perhaps it should be called /reference instead of /transports?
Either way, one half of the API will feel a bit off.

Signed-off-by: Miloslav Trmač <[email protected]>
This allows the DockerReference-only refImageReferenceMock to be a bit
tighter about rejecting unexpected calls, and it will be useful
soon when policy is handled separately from DockerReference.

At the moment this does not change much, separately commited primarily
to ease reviewing.

Signed-off-by: Miloslav Trmač <[email protected]>
This requires some new and expanded mocks instead of cheating and
passing nil objects.

Signed-off-by: Miloslav Trmač <[email protected]>
@mtrmac
Copy link
Collaborator Author

mtrmac commented Jul 16, 2016

Marked as WIP because I need to re-integrate into mtrmac/image:integrate-all-the-things before being 100% certain, and a corresponding skopeo branch is missing; but it is very unlikely that anything in this PR will change.

@mtrmac
Copy link
Collaborator Author

mtrmac commented Jul 16, 2016

This is fairly test-heavy, especially considering how trivial some of the *_transport.go methods are; the reason for that is that the policy evaluation and signature verification code will depend on some of the methods (and they will become somewhat less trivial), and it is simpler to just ensure that everything in *_transport.go will have perfect test coverage than to keep thinking about which parts truly need the tests and which don’t.

This was referenced Jul 16, 2016
@mtrmac mtrmac changed the title WIP: Reference abstraction Reference abstraction Jul 18, 2016
@mtrmac
Copy link
Collaborator Author

mtrmac commented Jul 18, 2016

OK, full chain all the way to skopeo:integrate-all-the-things is updated and working, and this works with

make test-skopeo SKOPEO_REPO=mtrmac/skopeo SKOPEO_BRANCH=reference-abstraction

aka containers/skopeo#144 .

Please review.

// (not as the image itself, or its underlying storage, claims). Should be fully expanded, i.e. !reference.IsNameOnly.
// This can be used e.g. to determine which public keys are trusted for this image.
// May be nil if unknown.
IntendedDockerReference() reference.Named
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

glad you remove those

@runcom
Copy link
Member

runcom commented Jul 18, 2016

lgtm just a question

Approved with PullApprove

@mtrmac
Copy link
Collaborator Author

mtrmac commented Jul 18, 2016

👍 Thanks!

Approved with PullApprove

@mtrmac mtrmac merged commit 2742dc1 into containers:master Jul 18, 2016
@mtrmac mtrmac deleted the reference-abstraction branch July 18, 2016 14:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants