This repository has been archived by the owner on Aug 14, 2020. It is now read-only.
discovery: match template only if satisfies all required labels #580
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is the first part that tries to implement #575 second proposal (remove the "hidden" behavior that sets a version label to "latest" if not provided)
Actually, the spec isn't clear on template rendering and matching and can block some meta tags implementation as, the current implementation, can return unwanted endpoints.
It can probably BREAK some of the current meta tags implementations. But I'd like to ear your thoughts on this since I cannot find better ideas.
discovery: match only templates that satisfy all required labels
Actually the spec doesn't clarify when an endpoint template should be accepted or
not. Now, the appc/spec implementation returns only endpoints that can
be fully rendered. This means that it will also accept a template if it
doesn't contain some of the required discovery labels.
This looks good, but, trying to implement some meta discovery ideas it
will bring to unwanted endpoints.
Example 1:
Suppose I want to implement the "latest" pattern behavior:
If, on discovery, I ask for the name, os and arch
labels only the second template will be rendered (since the first cannot
be fully rendered due to missing version label). So I achieved latest
pattern.
But if I'm asking for a specific version both templates will be
rendered.
Example 2:
As an extension of the first example, suppose I want to create a global
meta discovery for all my images on example.com. So on the root of my
server I'll put some meta tags using example.com as prefix:
With these tags I want to implement a "latest" and also "noarch" pattern.
If, on discovery, I ask only for the name and version labels the
second template will be rendered. So I achieved noarch pattern.
But, unfortunately, also the last template will be rendered.
And, as the first example, if I'm asking for a specific name,
version, os and arch ALL the templates will be rendered.
Since the spec says:
If an implementation chooses the second it can download the wrong image version.
This patch makes template matching stricter choosing only template that
fully satisfy the required labels.
It can probably BREAK some of the current meta tags implementations.
It also documents this behavior.