This replaces the copy of github.com/docker/docker/reference in the same
place, which we have just gotten rid of, and allows using this package
even in consumers which insist on an incompatible version of
docker/distribution.
The copy has been edited to drop a reference to
github.com/docker/distribution/digestset .
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Instead call distreference.ParseNormalizedNamed directly.
(This looks bigger than it really is because so many files now don't
need c/i/docker/reference, so they are dropping the “distreference”
qualifier for docker/distribution/reference.)
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Instead of rebuilding it as name/name+digest/name+tag, just use the
return value from distreference.ParseNormalizedName without
modification.
THIS CHANGES BEHAVIOR: before, name@tag:digest inputs were silently
trated as name:digest, dropping the tag; now the semantics is correctly
preserved.
We already anticipate such strings as references in docker: and
docker-daemon: (where they are now rejected) and in signature
verification (where, unless we check repository names only, they must
match exactly).
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Instead call distreference.FamiliarString() for SOME uses, generally for
error messages and StringWithinTransport().
In signature/policy_reference_match.go and signature/docker.go, where we
care about equality but not exactly about the kind of normalization, call
XNamed.String() instead, with the same rationale as the earlier
Name/FamiliarName choice.
In copy.Image, when creating a singature, use .String() (i.e. the fully
explicit form), for that extra bit of safety.
In tests, generally use the simpler .String() and modify expected
results, instead of calling FamilarString().
XNamed is now equivalent to distreference.Named, all the extra methods
have went away.
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Instead call distreference.FamiliarName() in SOME uses.
In signature/policy_reference_match.go, where we care about equality but
not exactly about the kind of normalization, call XNamed.Name()
instead. That compares the fully-explicit instaed of the
fully-minimized name forms. If both canonicalizations are consistent,
this should not matter—and if they weren’t, using the fully explicit
form should be safer. (Also, .Name() is likely to be a bit faster, but
that really doesn’t matter all that much.)
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Now that namedRef.our values are only used for computing other
namedRef.our values, drop the struct member and all code computing it,
including the entirety of our normalization code.
We still keep .upstream as a private member instead of using
distreference.Named directly, or making namedRef an implementation of
distreference.Named.
BEHAVIOR CHANGE: We used to minimize the input and then check whether it
is a 64-char hex string, now distreference.ParseNormalizedNamed first
checks for a 64-char hext string and then normalized (and by expanding,
not minimizing). Hence, things like docker.io/$64hexchars are now
accepted, which is a behavior change (noticed by the tests). Though,
there is really no risk of confusing such a value with a digest reference,
so this behavior change seems quite acceptable.
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
This is an intermediate step which will eventually go away.
The goal of this PR is to get rid of c/i/docker/daemon/reference and to
replace uses of it by direct calls to docker/distribution/reference.
We can't do that safely and easily, because the two have different
semantics for reference.Named.Name() and reference.Named.String(): we
return a minimized version, e.g. "busybox", upstream returns an expanded
version, e.g. "docker.io/library/busybox".
BEFORE this commit the difference is hidden by using
docker/distribution/reference.WithName, which allows using the minimized
version, and works with it correctly; but because we want to use the
upstream canonicalization code, which will change semantics, we can't
just mix and match.
To make the distinction explicit, this commmit adds an X to ALL public
names from c/i/docker/daemon/reference. E.g. a reference.XNamed type,
which has methods XName and XString.
This is pretty large, but does not change behavior at all. By
inspection it is clear to see that reference.XNamed and subtypes does
not expose any of the non-X, conflicting, method names.
Using e.g.
> git diff --word-diff-regex=.|grep -F '{+'|grep -v '^\([^{]\|{+X+}\)*{\?$'
it is possible to see that most lines in this diff only add a single X
letter, and manually inspect the few lines which don't match the regexp.
The only REALLY new code is an explicit definition of namedRef.XName()
and namedRef.XString(), and two newly added casts to namedRef in cases
where we need to use the underlying distreference.Reference within
a reference.XNamed value. Strictly speaking these changes change
behavior, in that third-party implementations of reference.XNamed are no
longer accepted; but we broke them by renaming at all.
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
There has been a change in upstream (docker/distribution), where they
now require users of the digest library to load algorithms into the
binary (in other words they do .Available checks on crypto algorithms).
This fixes the unit test failures with "unsupported digest algorithm".
Signed-off-by: Aleksa Sarai <asarai@suse.de>