Go requires "deprecated" comments to have an empty line before them,
and to not be all-caps.
This updates to the comment so that it's correctly picked up as deprecated.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit 3c71f4933d)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Signed-off-by: Zou Nengren <zouyee1989@gmail.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit 79d1901549)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
ParseDockerRef normalizes the image reference following the docker
convention. This is added mainly for backward compatibility. The reference
returned can only be either tagged or digested. For reference contains both tag
and digest, the function returns digested reference, e.g.
docker.io/library/busybox:latest@sha256:7cc4b5aefd1d0cadf8d97d4350462ba51c694ebca145b08d7d41b41acc8db5aa
will be returned as
docker.io/library/busybox@sha256:7cc4b5aefd1d0cadf8d97d4350462ba51c694ebca145b08d7d41b41acc8db5aa.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit 0ac367fd6b)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This updates the grammar to allow more than one digest algorithm
separator, matching the regular expression and intended grammar.
Signed-off-by: Stephen J Day <stephen.day@docker.com>
The common use case for this function is to add a default tag if the
reference only has a name. The current behavior only adds the default
tag if there is no *tag*, which requires most callers to check for a
digest. Change the behavior to only add default tags to name-only
references, and change the name to reflect this. The documentation
already described the new behavior, so it does not need to be changed.
Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
The identifier fields were using spaces while the rest
of the lines were using tabs!
Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
The NormalizedNamed interface has shown to not be necessary for
integrating the change downstream. The FamiliarName and FamiliarString
helpers are the only used interface and allow hiding the normalized
completely.
Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
Officials repositories always have 2 part names with the first part
being library and second part being the offical repository name. Names
with more than 2 parts should not hit the special case for official
repositories since they are not valid official repositories.
Add tests for this ambiguity and to ensure that 3 part names are
supports for the default repository, as used by the docker store.
Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
NamedRepository only needs to be used internally. Additionally this
interface may go away in the future and be merged with Named.
Signed-off-by: Derek McGowan <derek@mcgstyle.net> (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 <derek@mcgstyle.net> (github: dmcgowan)
Allows having other parsers which are capable of unambiguously keeping domain and path separated in a Reference type.
Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
Add a simple helper to create name only references without having
to first get the name as a string and reparse. This method does
not fail so ignoring or checking error to simply trim reference
is not required.
Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
When WithDigest is called on a reference that has a tag, it should
preserve the tag.
When WithTag is called on a reference that has digest, it should
preserve the digest.
Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
Use the same error message as is used in
docker/reference/reference.go to provide
slightly more information about the error.
This change tests if the reference passes
after lowercasing its characters, to determine
if the reference was invalid due to
it containing uppercase characters.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This allows hostnames to contain uppercase characters, matching behavior
in Docker versions before 1.10. It does not attempt to canonicalize
hostnames into a lowercase format before parsing, since this could lead
to corner cases (for example, making Hostname.Domain.Com/ref ambiguous
on a daemon which contains references for both hostname.domain.com/ref
and Hostname.Domain.Com/ref).
Fixes: #1433
Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
To resolve some inconsistencies between the grammar and the regular
expressions, the grammar has been slightly refactored to match the intent. The
regular expressions have been redefined with the same structure to make it
easier to verify the grammar is correct.
Signed-off-by: Stephen J Day <stephen.day@docker.com>
There is a constraint on the length of the name in a reference, so
WithName should be checking this instead of potentially creating a
reference that doesn't comply with the rules.
Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
This was using a different regexp from the intended one. This meant that
tags with uppercase characters were not accepted.
Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
Various improvements motivated by early real-world use in engine code
under development:
- Make `WithDigest` return `Canonical`, since the return value always
has a name and a digest.
- Introduce a `NamedTagged` type, which can be used for strongly typing
cases where something must have a name and a tag.
- Rename `ParseNamed` to `WithName`, and create a
`ParseNamed` that accepts tags and digests (returning a `Named` type).
The new `ParseNamed` makes code using the reference package much less
verbose, since typical use cases require a name, and this is an
additional type assertion and error case after every `Parse` call.
Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
These functions allow a Named type to be combined with a tag or a
digest. WithTag will replace the ImageReference function in
github.com/docker/docker/utils as the Docker Engine transitions to the
reference package.
Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
In order to support valid hostnames as name components, supporting repeated dash was added.
Additionally double underscore is now allowed as a separator to loosen the restriction for previously supported names.
Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)