Commit graph

18 commits

Author SHA1 Message Date
Sebastiaan van Stijn
6d4f62d7fd
reference: remove support for deprecated "shortid" refs
The "shortid" syntax was added in d26a3b37a6,
and allowed for matching an image on its ID prefix (this is before images were
content-addressable). With the introduction of content-addressable references,
this syntax became problematic, and Docker deprecated this syntax in 2016
(Docker v1.13.0) through commit; 5fc71599a0

> The `repository:shortid` syntax for referencing images is very little used,
> collides with tag references, and can be confused with digest references.

Support for this syntax was removed in 2017 (Docker 17.12) through commit:
a942c92dd7

containerd uses a fork of the reference package with this syntax removed, and
does not support this syntax:
901bcb2231

This patch removes the deprecated syntax, the ParseAnyReferenceWithSet function,
and the ShortIdentifierRegexp regex.

As there are no external consumers for this function, nor the regexp, I'm
skipping a deprecation cycle for this;

- https://grep.app/search?q=.ShortIdentifierRegexp
- https://grep.app/search?q=.ParseAnyReferenceWithSet%28

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-11-06 20:23:30 +01:00
Sebastiaan van Stijn
e0281dc609
format code with gofumpt
gofumpt (https://github.com/mvdan/gofumpt) provides a supserset of `gofmt` / `go fmt`,
and addresses various formatting issues that linters may be checking for.

We can consider enabling the `gofumpt` linter to verify the formatting in CI, although
not every developer may have it installed, so for now this runs it once to get formatting
in shape.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-11-03 22:48:20 +01:00
Antonio Ojea
53a6f7d7aa registry: support ipv6 addresses
Current registry reference use a subset of dns and IPv4 addresses to
represent a registry domain.

Since registries are mostly compatible with rfc3986, that defines the
URI generic syntax, this adds support for IPv6 enclosed in squared
brackets based on the mentioned rfc.

The regexp is only expanded to match on IPv6 addreses enclosed between
square brackets, considering only regular IPv6 addresses represented
as compressed or uncompressed, excluding special IPv6 address
representations.

Signed-off-by: Antonio Ojea <antonio.ojea.garcia@gmail.com>
2022-06-27 09:54:37 +02:00
Derek McGowan
90e62ac24c
Merge pull request #2979 from avtakkar/avtakkar/fix-domain-split
Fix bug in parsing domain from repository reference
2021-03-01 09:35:14 -08:00
Sebastiaan van Stijn
1d33874951
go.mod: change imports to github.com/distribution/distribution/v3
Go 1.13 and up enforce import paths to be versioned if a project
contains a go.mod and has released v2 or up.

The current v2.x branches (and releases) do not yet have a go.mod,
and therefore are still allowed to be imported with a non-versioned
import path (go modules add a `+incompatible` annotation in that case).

However, now that this project has a `go.mod` file, incompatible
import paths will not be accepted by go modules, and attempting
to use code from this repository will fail.

This patch uses `v3` for the import-paths (not `v2`), because changing
import paths itself is a breaking change, which means that  the
next release should increment the "major" version to comply with
SemVer (as go modules dictate).

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2021-02-08 18:30:46 +01:00
Aviral Takkar
a19e1847a3
Fix bug in parsing domain from repository reference
Signed-off-by: Aviral Takkar <aviral26@users.noreply.github.com>
2020-09-17 00:07:19 -07:00
Sebastiaan van Stijn
0ac367fd6b
Add reference.ParseDockerRef utility function
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>
2019-01-04 21:26:06 +01:00
Derek McGowan
69bdac7eff
Fix recursion with digest String
Update check for equal references to call the String method

Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
2017-01-20 11:38:07 -08:00
Derek McGowan
6170ac53da
Update ParseNamed to require canonical form
Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
2017-01-18 13:56:56 -08:00
Stephen Day
44eff0143e Merge pull request #2143 from dmcgowan/reference-familiar-match
reference: move match function to helpers
2017-01-13 18:32:33 -08:00
Derek McGowan
3b0497541a
Move match function to helpers
Update match function to operate on familiar names

Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
2017-01-13 17:08:46 -08:00
Derek McGowan
7cb0c15480 Merge pull request #2137 from dmcgowan/reference-ambiguous-library-namespace
Remove ambiguity for unsupported official repository input
2017-01-13 16:22:41 -08:00
Derek McGowan
63cb8cf23b
Remove NormalizedNamed from public interface
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)
2017-01-11 12:58:47 -08:00
Derek McGowan
24cbdc41ba
Remove ambiguity for unsupported official repository input
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)
2017-01-11 10:46:48 -08:00
Derek McGowan
0b1bcfda71
Add tests for splithostname on normalized values
Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
2017-01-09 16:52:05 -08:00
Derek McGowan
e0286a7de0
Use go-digest package
Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
2017-01-09 15:44:13 -08:00
Derek McGowan
429c75faf0
Add NormalizedName interface
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)
2017-01-05 16:57:11 -08:00
Derek McGowan
042fe9bf46
Move docker reference functionality to reference package
Add normalization functions and Docker specific domain splitting to
reference package.

Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
2017-01-05 15:43:27 -08:00