Commit Graph

247 Commits

Author SHA1 Message Date
22f9d9e216 Open up v2 http status code checks for put and head checks
Under certain cases, such as when putting a manifest or check for the existence
of a layer, the status code checks in session_v2.go were too narrow for their
purpose. In the case of putting a manifest, the handler only cares that an
error is not returned. Whether it is a 304 or 202 does not matter, as long as
the server reports success. Having the client only accept specific http codes
inhibits future protocol evolution.

Signed-off-by: Stephen J Day <stephen.day@docker.com>
Upstream-commit: 86aea582b66929c68de3346a26a26633b62a5784
Component: engine
2015-01-27 18:09:53 -08:00
29be632832 Merge pull request #10249 from jlhawn/distribution_version_header_10247
Split API Version header when checking for v2
Upstream-commit: b9650ad40bd4db3b570f30b158eb9494bb06da8c
Component: engine
2015-01-27 11:48:42 -08:00
e63f5dfefb Better error messaging and logging for v2 registry requests
Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
Upstream-commit: d277714614f62dba276227f70cc2a47eac6e02e7
Component: engine
2015-01-26 14:00:51 -08:00
c43f530252 Fix write after close on http response
Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
Upstream-commit: 12d83e727dd3522006b53afbcfac3cdce178117a
Component: engine
2015-01-21 15:14:01 -08:00
f38ca916fb Split API Version header when checking for v2
Since the Docker-Distribution-API-Version header value may contain multiple
space delimited versions as well as many instances of the header key, the
header value is now split on whitespace characters to iterate over all versions
that may be listed in one instance of the header.

Docker-DCO-1.1-Signed-off-by: Josh Hawn <josh.hawn@docker.com> (github: jlhawn)
Upstream-commit: 58c142bcfa2b9edce7efe72d393e9f90b9df9927
Component: engine
2015-01-21 15:08:32 -08:00
a90195f1c8 Resolve ambiguity on registry v2 ping
v2 ping now checks for a Docker-Distribution-API-Version
header that identifies the endpoint as "registry/2.0"

Docker-DCO-1.1-Signed-off-by: Josh Hawn <josh.hawn@docker.com> (github: jlhawn)
Upstream-commit: f46923be8eba81dd9e261554128b26a1c83ce398
Component: engine
2015-01-20 19:52:08 -08:00
b098aaedce Merge pull request #9784 from dmcgowan/v2-registry
Client Support for Docker Registry HTTP API V2
Upstream-commit: 8b95ad230e2ee76450ceb9a80aa8e942a56bb397
Component: engine
2015-01-19 10:46:38 -08:00
40a61d0eec Make .dockercfg with json.MarshallIndent
Fixes #10129
Makes the .dockercfg more human parsable.

Also cleaned up the (technically) racey login test.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Upstream-commit: b8f7526fc6333e5b67282e5b73eee497dd13ec34
Component: engine
2015-01-17 07:05:56 -05:00
fb2575c794 Add token cache
Token cache prevents the need to get a new token for every registry interaction.
Since the tokens are short lived, the cache expires after only a minute.

Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
Upstream-commit: dd914f91d779f64e20ce86767ab4f84f40b9ef6a
Component: engine
2015-01-15 14:05:06 -08:00
5598d30646 Cleanup v2 session to require endpoint
Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
Upstream-commit: 9c6f8e14398e794cbe20504556c22a1c83260bd8
Component: engine
2015-01-15 14:05:06 -08:00
e05bd85386 Fix list tags
Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
Upstream-commit: 1a9cdb13943c6af397472e235708cb10824681cd
Component: engine
2015-01-15 14:05:06 -08:00
07ca876ccc Refactor from feedback
Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
Upstream-commit: 25945a40c4f352a754cbd8dba9c846c7539fe463
Component: engine
2015-01-15 14:05:06 -08:00
c13d2851b8 Add Tarsum Calculation during v2 Pull operation
While the v2 pull operation is writing the body of the layer blob to disk
it now computes the tarsum checksum of the archive before extracting it to
the backend storage driver. If the checksum does not match that from the
image manifest an error is raised.

Also adds more debug logging to the pull operation and fixes existing test
cases which were failing. Adds a reverse lookup constructor to the tarsum
package so that you can get a tarsum object using a checksum label.

Docker-DCO-1.1-Signed-off-by: Josh Hawn <josh.hawn@docker.com> (github: jlhawn)
Upstream-commit: 213e3d116642431adbe634d39740eddc5a81e063
Component: engine
2015-01-15 14:05:05 -08:00
56c1f6c9e6 Correctly check and propagate errors in v2 session
Signed-off-by: Stephen J Day <stephen.day@docker.com>
Upstream-commit: 1b43144ad8597d0d0ca089042c1162ba668259ab
Component: engine
2015-01-15 14:05:05 -08:00
445a293eb7 Get token on each request
Signed-off-by: Derek McGowan <derek@mcgstyle.net>
Upstream-commit: d094eb6f7ffe6b608ecde54297e107e5caa0954d
Component: engine
2015-01-15 14:05:05 -08:00
21c36fbac8 Allow private V2 registry endpoints
Signed-off-by: Derek McGowan <derek@mcgstyle.net>
Upstream-commit: 7d61255f578bae7dc5c2a5d44c50bf32bbc9f568
Component: engine
2015-01-15 14:05:05 -08:00
bd2dadaee1 Update push and pull to registry 2.1 specification
Signed-off-by: Derek McGowan <derek@mcgstyle.net>
Upstream-commit: 0336b0cdaa74ac03003c4a933eb866fb0cec8125
Component: engine
2015-01-15 14:05:05 -08:00
93ab6ab93d Remove dependencies on registry packages
Because docker core cannot vendor non-master Go dependencies, we need to remove
dependencies on registry package. The definition of digest.Digest has been
changed to a string and the regular expressions have been ported from
docker-registry/common library.

We'll likely change this be dependent on the registry in the future when the
API stabilizies and use of the master branch becomes the norm.

Signed-off-by: Stephen J Day <stephen.day@docker.com>
Upstream-commit: dbb4b03bfc82eadefaf68c1a81d215949980550e
Component: engine
2015-01-15 14:05:05 -08:00
d8303cd325 Registry V2 HTTP route and error code definitions
This package, ported from next-generation docker regsitry, includes route and
error definitions. These facilitate compliant V2 client implementation. The
portions of the HTTP API that are included in this package are considered to be
locked down and should only be changed through a careful change proposal.
Descriptor definitions package layout may change without affecting API behavior
until the exported Go API is ready to be locked down.

When the new registry stabilizes and becomes the master branch, this package
can be vendored from the registry.

Signed-off-by: Stephen J Day <stephen.day@docker.com>
Upstream-commit: a0f92a26d90e870dfddae9694a5de97e36d3f586
Component: engine
2015-01-15 14:05:05 -08:00
0d8e8d5acb Update token response handling
Registry authorization token is now taken from the response body rather than
the repsonse header.

Docker-DCO-1.1-Signed-off-by: Josh Hawn <josh.hawn@docker.com> (github: jlhawn)
Upstream-commit: e23362597dcaa8839271210d24bda2ba55f1e12f
Component: engine
2015-01-15 14:05:05 -08:00
6614616033 Update push to use mount blob endpoint
Using mount blob prevents repushing images which have already been uploaded

Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
Upstream-commit: e9b590d85e9c622316b8be71004737f63e6b9503
Component: engine
2015-01-15 14:05:05 -08:00
6a46693a7d Push flow
Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
Upstream-commit: 188b56c836e49e3c888e1e27e4e26b5cc0f1caaa
Component: engine
2015-01-15 14:05:05 -08:00
e89bb2e57b Adds support for v2 registry login
summary of changes:

registry/auth.go
  - More logging around the login functions
  - split Login() out to handle different code paths for v1 (unchanged logic)
    and v2 (does not currently do account creation)
  - handling for either basic or token based login attempts
registry/authchallenge.go
  - New File
  - credit to Brian Bland <brian.bland@docker.com> (github: BrianBland)
  - handles parsing of WWW-Authenticate response headers
registry/endpoint.go
  - EVEN MOAR LOGGING
  - Many edits throught to make the coad less dense. Sparse code is more
    readable code.
  - slit Ping() out to handle different code paths for v1 (unchanged logic)
    and v2.
  - Updated Endpoint struct type to include an entry for authorization
    challenges discovered during ping of a v2 registry.
  - If registry endpoint version is unknown, v2 code path is first attempted,
    then fallback to v1 upon failure.
registry/service.go
  - STILL MOAR LOGGING
  - simplified the logic around starting the 'auth' job.
registry/session.go
  - updated use of a registry.Endpoint struct field.
registry/token.go
  - New File
  - Handles getting token from the parameters of a token auth challenge.
  - Modified from function written by Brian Bland (see above credit).
registry/types.go
  - Removed 'DefaultAPIVersion' in lieu of 'APIVersionUnknown = 0'`

Docker-DCO-1.1-Signed-off-by: Josh Hawn <josh.hawn@docker.com> (github: jlhawn)
Upstream-commit: 41e20cecb9944137de82ff5fa0898f953aa2bf87
Component: engine
2015-01-15 14:04:14 -08:00
8b29f19b21 Fix format calls as suggested by vet
Signed-off-by: Alexander Morozov <lk4d4@docker.com>
Upstream-commit: a75b02fe72f3da73f9788919ff2c22f183978db7
Component: engine
2015-01-14 14:12:03 -08:00
be31b29591 registry: fix minor type
Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
Upstream-commit: 7724260224c69eeb948c75c247d4868256e5081a
Component: engine
2015-01-09 09:06:27 +08:00
196597b4ad Moving NewIndexInfo, NewRepositoryInfo and associated helpers into config.go
Signed-off-by: Don Kjer <don.kjer@gmail.com>
Upstream-commit: 6f0068f2733232b8357c2308517f6ddddb63aace
Component: engine
2015-01-08 20:15:00 +00:00
5aa04a56fb Deprecating ResolveRepositoryName
Passing RepositoryInfo to ResolveAuthConfig, pullRepository, and pushRepository

Moving --registry-mirror configuration to registry config

Created resolve_repository job

Repo names with 'index.docker.io' or 'docker.io' are now synonymous with omitting an index name.

Adding test for RepositoryInfo

Adding tests for opts.StringSetOpts and registry.ValidateMirror

Fixing search term use of repoInfo

Adding integration tests for registry mirror configuration

Normalizing LookupImage image name to match LocalName parsing rules

Normalizing repository LocalName to avoid multiple references to an official image

Removing errorOut use in tests

Removing TODO comment

gofmt changes

golint comments cleanup.  renaming RegistryOptions => registry.Options, and RegistryServiceConfig => registry.ServiceConfig

Splitting out builtins.Registry and registry.NewService calls

Stray whitespace cleanup

Moving integration tests for Mirrors and InsecureRegistries into TestNewIndexInfo unit test

Factoring out ValidateRepositoryName from NewRepositoryInfo

Removing unused IndexServerURL

Allowing json marshaling of ServiceConfig.  Exposing ServiceConfig in /info

Switching to CamelCase for json marshaling

PR cleanup; removing 'Is' prefix from boolean members.  Removing unneeded json tags.

Removing non-cleanup related fix for 'localhost:[port]' in splitReposName

Merge fixes for gh9735

Fixing integration test

Reapplying #9754

Adding comment on config.IndexConfigs use from isSecureIndex

Remove unused error return value from isSecureIndex

Signed-off-by: Don Kjer <don.kjer@gmail.com>

Adding back comment in isSecureIndex

Signed-off-by: Don Kjer <don.kjer@gmail.com>
Upstream-commit: 568f86eb186731b907b659e4ec64bda21c2fe31d
Component: engine
2015-01-08 20:14:58 +00:00
521cb78a14 Allow hyphens in namespaces.
Signed-off-by: Matthew Riley <mattdr@google.com>
Upstream-commit: 6c126d443b3ee3bbb6d0a437a1b5c51cbf9e47f2
Component: engine
2015-01-05 11:06:16 -08:00
3ee3e640f2 registry: remove accidentally added --insecure-registry feature
If `--insecure-registry mydomain.com` was specified, it would match a registry at mydomain.com on any port.
This was accidentally added in #9735 and is now being reverted.

Signed-off-by: Tibor Vass <teabee89@gmail.com>
Upstream-commit: 9a50dd5f37d001d7c453ea8749454b4c8bf728f1
Component: engine
2014-12-19 16:46:29 -05:00
11159bae89 registry: handle unresolvable domain names in isSecure
to allow HTTP proxies to work as expected.

Fixes #9708

Signed-off-by: Tibor Vass <teabee89@gmail.com>
Upstream-commit: ff4bfcc0e9f171a95dac5cc2650faacf73943057
Component: engine
2014-12-18 19:16:55 -05:00
3b8d2a3264 registry: add tests for unresolvable domain names in isSecure
Signed-off-by: Tibor Vass <teabee89@gmail.com>
Upstream-commit: a70d7aaf282948c6873c03031cee0704cbe86476
Component: engine
2014-12-18 19:16:55 -05:00
d6330f220b Chnage LookupRemoteImage to return error
This commit is patch for following comment
// TODO: This method should return the errors instead of masking them and returning false

Signed-off-by: Daehyeok Mun <daehyeok@gmail.com>
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
Upstream-commit: 8123c1e9fef0eb0d6b4e89dce4089276b751906c
Component: engine
2014-12-16 16:23:19 -08:00
24d7379326 validate image ID properly & before load
Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com>

Conflicts:
	graph/load.go
Upstream-commit: bff1d9dbce76bed1e267a067eb4a1a74ef4da312
Component: engine
2014-12-11 16:29:27 -05:00
807e0b468d Refactor put image function's redirect loop
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
Upstream-commit: 9a7a1e5be01b829e64b32a8b0f1d260f0a2a45c3
Component: engine
2014-12-10 18:11:27 -08:00
e42acc43c3 Prevent loop with var overshadowing
Incase of a 3xx redirect the var was being overshowed and ever changed
causing an infinite loop.

Fixes #9480

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
Upstream-commit: 3b4de1070fac41c400c22f200438c90823e7769d
Component: engine
2014-12-10 17:43:21 -08:00
c33d4c9307 registry: fix ServerAddress setting
This ensures that ServerAddress is set, while previously it was getting
set after configFile.Configs.

Signed-off-by: Vaidas Jablonskis <jablonskis@gmail.com>
Upstream-commit: d96832cbd2c62103944518866e1fc1219ce048d5
Component: engine
2014-11-24 18:26:41 +00:00
ea3d6b1b0d Add the possibility of specifying a subnet for --insecure-registry
Signed-off-by: Tibor Vass <teabee89@gmail.com>
Upstream-commit: 6aba75db4e7b0151aeb48f450bb43e659ce0ec82
Component: engine
2014-11-14 12:31:11 -08:00
2e493e1f52 registry: parse INDEXSERVERADDRESS into a URL for easier check in isSecure
Signed-off-by: Tibor Vass <teabee89@gmail.com>
Upstream-commit: fbe10c83d81843412fd3485a8d6bb75849de97d4
Component: engine
2014-11-13 07:02:24 -08:00
fdd71c9652 Put mock registry address in insecureRegistries for unit tests
Signed-off-by: Tibor Vass <teabee89@gmail.com>
Upstream-commit: 78e859f3c35d1f31e7d6f3ded9a414dc0fbb8eaa
Component: engine
2014-11-12 20:34:03 -06:00
166cb2e350 registry: refactor registry.IsSecure calls into registry.NewEndpoint
Signed-off-by: Tibor Vass <teabee89@gmail.com>
Upstream-commit: 4455f517605f1fd7279bbe9547915f15c037997d
Component: engine
2014-11-12 20:34:03 -06:00
f8e94225af registry: always treat 127.0.0.1 as insecure for all cases anytime anywhere
Docker-DCO-1.1-Signed-off-by: Erik Hollensbe <github@hollensbe.org> (github: erikh)
Upstream-commit: 11380a109e53bc5f388b6212c12794609c0241eb
Component: engine
2014-11-12 12:14:43 -08:00
dc8c6e365a registry: default --insecure-registry to localhost and 127.0.0.1
Signed-off-by: Johan Euphrosine <proppy@google.com>
Upstream-commit: 28ee373e19bbfdf47c747f6fd9385a8a75f0a483
Component: engine
2014-11-12 09:12:42 -08:00
a4433b9e0f Merge pull request #9095 from proppy/is-secure-test
registry: add tests for IsSecure
Upstream-commit: e08d1f6af2de6f0a402bd0e5c26fb5093fda378e
Component: engine
2014-11-11 16:52:36 -05:00
cc91da7978 registry: add tests for IsSecure
Signed-off-by: Johan Euphrosine <proppy@google.com>
Upstream-commit: 75e3b35bf15dd01363f8b422d6b8a4a62b1054c6
Component: engine
2014-11-11 11:02:32 -08:00
8b766a1400 registry: don't iterate through certs
the golang tls.Conn does a fine job of that.
http://golang.org/src/pkg/crypto/tls/handshake_client.go?#L334

Signed-off-by: Vincent Batts <vbatts@redhat.com>
Upstream-commit: a368e064a972ab75561ee50067a3168b9d8d277e
Component: engine
2014-11-04 16:12:23 -05:00
1b58e19e34 Fix login command
Signed-off-by: Tibor Vass <teabee89@gmail.com>
Upstream-commit: 05c18a2434ab7bd68a86c87fe866bc7107ac1941
Component: engine
2014-10-30 19:44:44 -04:00
6d16ddef35 Do not verify certificate when using --insecure-registry on an HTTPS registry
Signed-off-by: Tibor Vass <teabee89@gmail.com>

Conflicts:
	registry/registry.go
	registry/registry_test.go
	registry/service.go
	registry/session.go

Conflicts:
	registry/endpoint.go
	registry/registry.go
Upstream-commit: 6a1ff022b0744213ed588d9c16dbb13ce055eda6
Component: engine
2014-10-30 19:44:09 -04:00
ff11c586b2 Don't hard code true for auth job
Signed-off-by: Michael Crosby <michael@docker.com>

Conflicts:
	registry/service.go
Upstream-commit: afade4236d3f15704653132c364d6e7ccc975f8b
Component: engine
2014-10-30 19:41:55 -04:00
2339e91d29 Refactor IsSecure change
Fix issue with restoring the tag store and setting static configuration
from the daemon. i.e. the field on the TagStore struct must be made
internal or the json.Unmarshal in restore will overwrite the insecure
registries to be an empty struct.

Signed-off-by: Michael Crosby <michael@docker.com>

Conflicts:
	graph/pull.go
	graph/push.go
	graph/tags.go
Upstream-commit: f29b2e48ebfb171f58375b6e355910fc2192aceb
Component: engine
2014-10-30 19:41:55 -04:00
6b54bde512 make http usage for registry explicit
Docker-DCO-1.1-Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com> (github: unclejack)

Conflicts:
	daemon/config.go
	daemon/daemon.go
	graph/pull.go
	graph/push.go
	graph/tags.go
	registry/registry.go
	registry/service.go
Upstream-commit: 380c8320a78dc16da65d9d13004422ac5a0cca53
Component: engine
2014-10-30 19:41:55 -04:00