Commit Graph

240 Commits

Author SHA1 Message Date
Antonio Murdaca
e775248b96 move dockerutils under docker/utils
also remove fixtures pkg as it would clutter godoc (there's not need
to have a .go files with fixtures)

Signed-off-by: Antonio Murdaca <runcom@redhat.com>
2016-05-17 17:35:32 +02:00
Antonio Murdaca
df618e5f7a Merge pull request #58 from mtrmac/api-general
General image API cleanups
2016-05-17 15:58:08 +02:00
Miloslav Trmač
6a357b6fcc Add comments on the use of the API and the general direction. 2016-05-17 15:50:17 +02:00
Miloslav Trmač
7598aab521 Clean up Image.Inspect
This does not change behavior.

Rename types.DockerImageManifest to types.ImageInspectInfo.

This naming more accurately reflects what the function does and how it is
expected to be used.

(The only outstanding non-inspection piece is the Name field, which is
kind of a subset of GetIntendedDockerReference() right now. Not sure
whether that is intentional.)

Also fold makeImageManifest into its only user.
2016-05-16 20:50:46 +02:00
Miloslav Trmač
9766f72760 Move listing of repository tags from Image.Manifest to a separate Image.GetRepositoryTags
This does not change behavior.

Splits listing of repository tags, which is not a property of an image,
from the image.Manifest gathering of information about an image.
2016-05-16 20:50:46 +02:00
Miloslav Trmač
60e8d63712 Compute the digest in (skopeo inspect) instead of trusting the registry
Compute the digest ourselves, the registry is in general untrusted and
computing it ourserlves is easy enough.

The stop passing the unverifiedCanonicalDigest value around, simplifying
ImageSource.GetManifest and related code.  In particular, remove
retrieveRawManifest and have internal users just call Manifest() now that
we don't need the digest.
2016-05-16 20:50:45 +02:00
Miloslav Trmač
e3d257e7b5 Decouple (skopeo inspect) output formatting from types.Image.Manifest
Does not change behavior.

This will allow us to move collecting some of the data to the (skopeo
inspect) code and to have a more focused types.Image API, where
types.Image.Manifest() does not return a grab bag of manifest-unrelated
data, eventually.

For how it actually makes the coupling more explicit by having
types.Image.Manifest() return a types.DockerImageManifest instead of the
too generic types.ImageManifest.  We will need to think about which
parts of DockerImageManifest are truly generic, later.
2016-05-16 20:50:45 +02:00
Antonio Murdaca
c75f0f6780 Merge pull request #59 from mtrmac/api-for-signatures
API for signatures - drop Get prefixes on quick getters
2016-05-16 20:43:48 +02:00
Miloslav Trmač
c38ed76969 Rename GetIndendedDockerReference to IntendedDockerReference 2016-05-16 20:33:13 +02:00
Miloslav Trmač
119609b871 Drop the Get prefix from types.Image.GetManifest and GetSignatures
Keeps the Get prefix on the equivalent methods on types.ImageSource, to
hint that they may be slow.
2016-05-16 20:29:52 +02:00
Miloslav Trmač
dc7a05ebf9 Rename types.Image.Manifest to types.Image.Inspect
Does not change behavior.

This better expresses the purpose of this method (it is working with
more, currently much more, than the manifest), and frees up the Manifest
method name for a simple getter of the raw blob.
2016-05-16 20:24:39 +02:00
Antonio Murdaca
d4eb69e1ab Merge pull request #57 from mtrmac/api-for-signatures
API for signatures
2016-05-16 20:10:03 +02:00
Miloslav Trmač
e4913bd0b0 Add GetIntendedDockerReference to types.Image and types.ImageSource
This will be necessary for signature verification and related policy
evaluation in the future.
2016-05-16 19:25:11 +02:00
Miloslav Trmač
feb9de4845 Add GetManifest and GetSignatures to types.Image
No change in behavior.

These functions are guaranteed-cached versions of the same method in
types.ImageSource.  Both will be needed for signature policy evaluation,
and the symmetry with ImageSource is nice.

Also replaces the equivalent RawManifest method, preferring to keep
the same naming convention as types.ImageSource.
2016-05-16 19:25:11 +02:00
Antonio Murdaca
a39474c817 Merge pull request #56 from mtrmac/sub-pkgs
Move directory, docker and openshift from cmd/skopeo to their own subpackages
2016-05-16 18:44:18 +02:00
Miloslav Trmač
f526328b30 Move directory, docker and openshift from cmd/skopeo to their own subpackages
Does not change behavior.  This is a straightforward move and update of
package references, except for:

- Adding a duplicate definition of manifestSchema1 to
  cmd/skopeo/copy.go.  This will need to be cleaned up later, for now
  preferring to make no design changes in this commit.
- Renaming parseDockerImage to NewDockerImage, to both make it public
  and consistent with common golang conventions.
2016-05-16 18:32:32 +02:00
Antonio Murdaca
b48c78b154 Merge pull request #54 from mtrmac/cleanups
signature cleanups
2016-05-16 16:01:12 +02:00
Miloslav Trmač
c8d8608b57 Move the x() helper from signature_test.go to json_test.go
It will be used in other tests as well.
2016-05-16 14:57:05 +02:00
Miloslav Trmač
35ba0edf0d Remove an unused savedEnvironment type 2016-05-16 14:57:05 +02:00
Miloslav Trmač
345d0c3e2b Reset a json.Unmarshal destination right before the call
… similar to how we do it in other places.
2016-05-16 14:57:05 +02:00
Miloslav Trmač
2ddaa122ab s/tryUnmarshalModified/tryUnmarshalModifiedSignature/g
We will be adding similar test helpers for other types as well, so avoid
the naming conflict.
2016-05-16 14:57:05 +02:00
Miloslav Trmač
7f7c71836c Move strict JSON parsing utilities into a separate file.
No semantic change, only a reorganization: The utilities now return
jsonFormatError instead of InvalidSignatureError, but their only
caller maps it back.
2016-05-16 14:57:05 +02:00
Miloslav Trmač
b5e8413d22 Add compile-time checks that privateSignature implements json.Marshaler and json.Unmarshaler 2016-05-16 14:57:05 +02:00
Miloslav Trmač
14686616c1 Add an API stability warning to mechanism.go 2016-05-16 14:57:05 +02:00
Antonio Murdaca
c89bc5cc4a Merge pull request #53 from mtrmac/copy-no-digest
Don‘t write the mainfest digest on stdout in (skopeo copy)
2016-05-14 10:01:00 +02:00
Miloslav Trmač
6db8872406 Don‘t write the mainfest digest on stdout in (skopeo copy)
The dir: source type does not return the value, the value is
untrusted/not validated, and it is not at all clear why we should print
it in the first place.
2016-05-11 17:36:02 +02:00
Miloslav Trmač
a4fba7b0a0 Merge pull request #51 from projectatomic/refactor-for-lib
*: move pkg main into cmd/skopeo/
2016-05-10 12:29:11 +02:00
Antonio Murdaca
3dc3957607 *: move pkg main into cmd/skopeo/
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
2016-05-10 11:04:03 +02:00
Antonio Murdaca
0bd8bea9ec Merge pull request #50 from jwhonce/wip/manpage
Correct man page formatting
2016-05-09 23:20:40 +02:00
Jhon Honce
780bd132ac Correct man page formatting
Signed-off-by: Jhon Honce <jhonce@redhat.com>
2016-05-09 13:48:31 -07:00
Miloslav Trmač
dbdb03eddb Merge pull request #49 from projectatomic/split-docker
*: split docker.go for future pkg creation
2016-05-09 21:30:38 +02:00
Antonio Murdaca
f43a92a78f *: split docker.go for future pkg creation
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
2016-05-09 21:13:17 +02:00
Antonio Murdaca
9229d72a37 Merge pull request #48 from mtrmac/gpgme-update
Rerun hack/vendor.sh to pick up gpgme changes
2016-05-07 11:35:49 +02:00
Miloslav Trmač
5a2b4005bb Rerun hack/vendor.sh to pick up gpgme changes
In particular, https://github.com/proglottis/gpgme/pull/8 .
2016-05-07 02:33:51 +02:00
Antonio Murdaca
9d24de4c57 Merge pull request #45 from mtrmac/gpgme-update
Rerun hack/vendor.sh to pick up gpgme changes
2016-05-06 22:58:53 +02:00
Miloslav Trmač
fe37c71a4f Rerun hack/vendor.sh to pick up gpgme changes
See https://github.com/proglottis/gpgme/pull/7 for the full discussion.

Resolves #42 .
2016-05-06 22:44:30 +02:00
Antonio Murdaca
28973c0a2d Merge pull request #43 from mtrmac/openshift-copypasta
Add Atomic Registry support for push and pull, and a new “copy” command
2016-05-05 15:39:28 +02:00
Miloslav Trmač
026acb2a57 Add a --sign-by flag to the (skopeo copy) command.
This expects a GPG key fingerprint as a value of the argument (though
other key identification methods, like mitr@volny.cz, happen to work).

Do we need to namespace this (gpg:…)?

Note that this is unusable at the moment because only the dir: backend
implements storing signatures, and this backend does can not determine
the canonical Docker reference to use as a signed image identity.
2016-05-04 17:32:51 +02:00
Miloslav Trmač
da24e319af Add CanonicalDockerReference to ImageDestination
This is necessary to resolve the canonical form of a reference for
signing it.
2016-05-04 17:32:51 +02:00
Miloslav Trmač
2e48975b8b Add a "copy" command for copying images
This copies an image from ImageSource to ImageDestination, e.g.

skopeo copy atomic:mitr/busybox:latest dir:t-down # pull
skopeo copy dir:t-up atomic:mitr/busybox:latest # push
2016-05-04 17:32:51 +02:00
Miloslav Trmač
56f9c987a2 Add utilities for parsing Docker URIs into ImageSource and ImageDestination objects
This finally uses all of the ImageSource and ImageDestination
implementations, though these utilities are in turn not used yet.

Adds unresolved FIXME (FIXME!!) notes for the tlsVerify default value;
for now, the code follows the existing parseImage semantics.

Also note the naming inconsistency: dir:…, atomic:…, but
docker://… .  I think the non-// names are cleaner, but if we are
committed to docker://…, just being consistent might be better.
2016-05-04 17:32:51 +02:00
Miloslav Trmač
36d4353229 Add OpenShift implementations of ImageSource and ImageDestination
Note that this assumes that both (docker login) and (oc login) has
happened, the credentials can be read from the usual config files,
and that the default OpenShift instance should be used.

This includes copy&pasted/modified/simplified code from OpenShift
and Kubernetes, primarily for config file parsing and setting up
TLS and HTTP authentication.

This is much smaller than linking to the upstream OpenShift client
libraries, which via various abstractions and registration drag in much
(dozens of megabytes) more code.

The primary loss from this simplification is automatic conversions
between various versions of the API objects, both for the REST API and
for local configuration storage.

This does not contain downloading/uploading signatures, which depends on
server-side support.
2016-05-04 17:32:51 +02:00
Miloslav Trmač
935eee7592 Add an ImageDestination implementation for the Docker Registry
Note that this does not allow uploading under new tags; Docker Registry
requires the tag to be present within the manifest, i.e. we might need
to modify the (possibly signed) manifest.

For now, uploading manifests only identified by a digest is sufficient
for the Atomic Registry; tagging happens in OpenShift imagestreams.
2016-05-04 17:32:51 +02:00
Miloslav Trmač
0587501ff0 Split dockerClient from dockerImageSource
The dockerClient encapsulates makeRequest and authentication setup, and
will be shared between the pull and push code.

This is only a restructuring, does not change behavior.

The dockerImage->dockerImageSource->dockerClient inclusion chain is
somewhat ugly, hopefully eventually we will move the remaining
dockerImage functionality either to dockerutils or to the top level, and
then eliminate it.
2016-05-04 17:32:51 +02:00
Miloslav Trmač
2790d9a1c3 Make dockerutils.GuessManifestMIMEType public
The Docker Registry manifest upload should supply a Content-Type, and
guessing from the contents is the easiest we can do right now.

Also eliminate dockerutils.manifestMIMEType, it is making it too
difficult to use the returned value to be worth the extra safety.
2016-05-04 17:32:51 +02:00
Antonio Murdaca
696eb74918 Merge pull request #30 from mtrmac/cleanups
Cleanups
2016-05-04 17:29:14 +02:00
Miloslav Trmač
654050b7e8 Fix handling of !tlsVerify when certPath is not set 2016-05-04 17:19:59 +02:00
Miloslav Trmač
7bee2da169 Use the provided method in dockerImageSource.makeRequest instead of hard-coding GET 2016-05-04 17:19:59 +02:00
Miloslav Trmač
60fbdd3988 Do not assume GetManifest is called before other dockerImageSource methods
Call dockerImageSource.ping() in .makeRequest() if needed, instead of
expecting a caller to do it (which only happened in GetManifest).

This required splitting the URLs into the baseURL (dependent on .ping()
result) and the suffix (independent of it), which was a simplification
anyway.

Also rename WWWAuthenticate to wwwAuthenticate, it is a private cache
field.
2016-05-04 17:19:59 +02:00
Miloslav Trmač
14bc664b48 Remove a redundant dockerImageSource.makeRequest parameter
It is always computed in the same, or equivalent, way.

Also remove pingResponse.needsAuth, only used in the above.
2016-05-04 17:19:59 +02:00