Add support for layers from foreign sources#1725
Add support for layers from foreign sources#1725aaronlehmann merged 1 commit intodistribution:masterfrom
Conversation
fb843bb to
8191731
Compare
Current coverage is 50.24%
@@ master #1725 diff @@
==========================================
Files 121 107 -14
Lines 10579 9352 -1227
Methods 0 0
Messages 0 0
Branches 0 0
==========================================
- Hits 6537 4698 -1839
- Misses 3436 4173 +737
+ Partials 606 481 -125
|
|
I've updated the PR with changes to successfully validate manifests with foreign layers. With this update and the referenced Docker changes, I am able to push/pull foreign layers to a private registry. |
|
Any feedback? |
manifest/schema2/manifest.go
Outdated
| type LayerDescriptor struct { | ||
| distribution.Descriptor | ||
| // ForeignURL contains the foreign source URL of this layer. | ||
| ForeignURL string `json:"foreign_url,omitempty"` |
There was a problem hiding this comment.
URLs []string to allow more that one URL. I don't think there is any reason to call this "foreign".
There was a problem hiding this comment.
In general, this works because foreign and URL doesn't need to be combined. More precisely, the presence of URL shouldn't imply the foreign media type and vice versa.
There was a problem hiding this comment.
Would you expect a client to try to try each of the URLs in order until one succeeded?
|
@jstarks Looks like a good start. There may be some additions required in |
|
@stevvooe Thanks. I'll look at |
|
@stevvooe For The tricky part is that currently Thoughts? |
|
@jstarks I see. Since we aren't really communicating with the registry, it may not make sense to bake this into the client. Really, there needs to be some component that parses a manifest and figures out the set of operations. Currently, we really do this in the engine, so it's likely the proposed break down is fine. |
|
I've pushed an update that moves |
|
|
||
| - **`urls`** *array* | ||
|
|
||
| For an ordinary layer, this is empty, and the layer contents can be |
There was a problem hiding this comment.
Do we want to go more generic here?
|
LGTM |
| for _, u := range fsLayer.URLs { | ||
| pu, err := url.ParseRequestURI(u) | ||
| if err != nil || (pu.Scheme != "http" && pu.Scheme != "https") { | ||
| err = errors.New("invalid URL on layer") |
There was a problem hiding this comment.
pu, err := url.ParseRequestURI(u) creates a new err variable in the current scope, so when you assign to err here, you are not assigning the one you declare with var err error, and this error won't be caught by the check below.
It might be worth adding a simple unit test to make sure that valid URLs are accepted and invalid URLs, or URLs in the presence of the wrong mediatype, are rejected.
There was a problem hiding this comment.
Whoops, good catch. This is by far the most common mistake I make in Go...
I'll add a test.
There was a problem hiding this comment.
Fixed and test added.
This will be used to support downloading Windows base layers from Microsoft URLs. Signed-off-by: John Starks <jostarks@microsoft.com>
|
LGTM |
Add support for layers from foreign sources
This will be used to support downloading Windows base layers from Microsoft URLs.
You can see this change in full context at jstarks/docker@27b81d4.
cc @aaronlehmann