Integrate docker reference changes#1778
Conversation
Current coverage is 51.41% (diff: 72.36%)@@ master #1778 diff @@
==========================================
Files 129 129
Lines 11416 11531 +115
Methods 0 0
Messages 0 0
Branches 0 0
==========================================
- Hits 6991 5929 -1062
- Misses 3534 4851 +1317
+ Partials 891 751 -140
|
|
Added commit with functionality needed to replace Also considering adding an interface which has methods for |
reference/normalize.go
Outdated
| // Normalizer removes ambiguity in values to ensure | ||
| // parsing is done correctly and without partial valus. | ||
| type Normalizer interface { | ||
| Canonicalize(string) (string, error) |
There was a problem hiding this comment.
The use of the term canonical here and CanonicalName is confusing with the idea of the Canonical reference. Not sure what would be a more appropriate word.
Also would it make more sense for this interface just to take in a string and do the Named parsing. Originally I wanted to leave it as a package function so it could possible access unexported values without trying the docker implementation to the package anymore. However that is not currently the case and the implementation is already accessing unexported types.
|
Ping @stevvooe @aaronlehmann for feedback |
|
Discussed more with Stephen and came to a few decisions...
I am going to start implementing these changes, we can have a discussion of their individual merit while I get these changes implemented. Ping @aaronlehmann @RichardScothern |
|
I like most of these changes.
I'm not sure I like the name
How will the grammar distinguish between IDs and names that look like IDs? |
I am not sure we can have a top level grammar to represent the rules for ID parsing as well as normalization. I would prefer to keep the grammar as is along with the existing |
|
@aaronlehmann
The role of the grammar to be to identify best effort structure. If a name may be an ID, its really up to the caller to run that throw the ID filter before treating it as a name. The main general drawback to this approach is that a secure process requires knowing the entire ID set. |
|
I would also consider |
|
|
b79674e to
3a2a544
Compare
|
PTAL, this now has additions to the grammar so I want everyone looking at it. Function naming may still still does not feel right (such as |
reference/helpers.go
Outdated
|
|
||
| // SplitName is a helper function which parses the | ||
| // input as a name and returns name plus tag or digest | ||
| func SplitName(s string) (string, string, error) { |
There was a problem hiding this comment.
This isn't used internally, and I don't think we want to encourage outside callers to conflate digests and tags.
There was a problem hiding this comment.
I agree, I got it from here https://github.com/docker/engine-api/blob/master/types/reference/image_reference.go#L10 but even its use looks trivial. It would be better to be more explicit about parsing into a Named. It is possible for engine-api to use the normalized versions now as well.
3a2a544 to
dfe593b
Compare
|
Changed |
|
LGTM |
1 similar comment
|
LGTM |
|
I suggest we hold off on merging this until we go through the exercise of porting Docker Engine to use it, to make sure we got the details right. |
|
@aaronlehmann that is fair, I will link a branch of Docker with the integration soon, no rush on merging this |
|
Made a PR in my fork for reviewing the changes dmcgowan/docker#27. Noticeable changes:
|
|
Added |
|
I like the addition of the |
Allows having other parsers which are capable of unambiguously keeping domain and path separated in a Reference type. Signed-off-by: Derek McGowan <[email protected]> (github: dmcgowan)
Signed-off-by: Derek McGowan <[email protected]> (github: dmcgowan)
Add normalization functions and Docker specific domain splitting to reference package. Signed-off-by: Derek McGowan <[email protected]> (github: dmcgowan)
Add interface for for a normalized name and corresponding parser for that type. New normalized versions of all interfaces are not added since all type information is preserved on calls to Familiar. Signed-off-by: Derek McGowan <[email protected]> (github: dmcgowan)
6741755 to
429c75f
Compare
|
Rebased Added 2 helper functions to make easy to integrate into Docker |
|
Whoah, nice |
|
LGTM |
| legacyDefaultDomain = "index.docker.io" | ||
| defaultDomain = "docker.io" | ||
| defaultRepoPrefix = "library/" | ||
| defaultTag = "latest" |
There was a problem hiding this comment.
Any thoughts on exporting these? If we don't, downstream code will likely need to redefine them.
There was a problem hiding this comment.
I would prefer not to, ideally they are only used through functions and hidden from the callers. The places the default tag are used today should rather be using EnsureTagged. Other use is for logging, but the "default" tag is irrelevant to the logs, the useful information is that a reference was altered along with before/after.
Only other types used are here https://github.com/docker/docker/blob/master/registry/config.go#L258. That function will likely get replaced to use the parsers in this package to validate.
|
LGTM I think it would be a nice simplification to merge However, this would change the |
Allows having other parsers which are capable of unambiguously keeping hostname and name separated in a Reference type.
This is intended to address comments made for #1777 and lay the foundation for upstreaming changes from docker/docker. Leaving this as WIP so some of those changes can be included.