You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Impossible to simply interoperate with distribution/reference uses of digest.Digest #2130
where consumeDigest and produceDigest use a correctly typed digest.Digest.
This fails with
./x.go:18: cannot use digested.Digest() (type "github.com/docker/distribution/vendor/github.com/opencontainers/go-digest".Digest) as type "github.com/opencontainers/go-digest".Digest in argument to consumeDigest
./x.go:19: cannot use produceDigest() (type "github.com/opencontainers/go-digest".Digest) as type "github.com/docker/distribution/vendor/github.com/opencontainers/go-digest".Digest in argument to reference.WithDigest
The first failure can be worked around by using
consumeDigest(digest.Digest(digested.Digest()))
instead; the second one can’t be worked around at all AFAICS, because we need to convert the digest.Digest value to a type acceptable to reference.WithDigest, and a basic string is insufficient and the expected type "github.com/docker/distribution/vendor/github.com/opencontainers/go-digest".Digest cannot be named:
imports github.com/docker/distribution/vendor/github.com/opencontainers/go-digest: use of vendored package not allowed
AFAICS the only way to make this work with the existing docker/distribution is to give up on having a trivial go package, and to vendor a copy of github.com/docker/distribution with github.com/docker/distribution/vendor stripped. That forces a build / vendoring toolchain on a package which would otherwise be a simple stand-alone Go library built using a simple go build.
Would you consider dropping the vendor/opencontainers/go-digest subdirectory from your repo, and using the one from $GOPATH instead? Or, I don’t know, define type Digest digest.Digest in reference/reference.go so that the type has an accessible name that can be used in the workaround conversions?
Every package has different strategies for vendoring code. Unfortunately there is no good convention for only vendoring internally used packages (as opposed to packages which are exposed through the interface). We have found the best method for vendoring involves flattening the vendor directories to prevent this. However I don't think it is the responsibility of this package to strip vendors because they are exposed on the interface or change the code to work around it, this is (as painful as it can be at times) the responsibility of the importers vendoring tool to solve.
I do sympathize with this annoyance but I think the code and vendors are correct.
docker/docker recently moved from GOPATH munging to Go 1.6 vendoring and ran into similar issues: moby/moby#29362
They attempted to move the vendor directory under cmd to work around this: moby/moby#28080. However, that approach has downsides, and it was abandoned.
Activity
docker: reference: drop WithDigest to work with oci/go-digest
dmcgowan commentedon Jan 9, 2017
Every package has different strategies for vendoring code. Unfortunately there is no good convention for only vendoring internally used packages (as opposed to packages which are exposed through the interface). We have found the best method for vendoring involves flattening the vendor directories to prevent this. However I don't think it is the responsibility of this package to strip vendors because they are exposed on the interface or change the code to work around it, this is (as painful as it can be at times) the responsibility of the importers vendoring tool to solve.
I do sympathize with this annoyance but I think the code and vendors are correct.
aaronlehmann commentedon Jan 9, 2017
docker/dockerrecently moved fromGOPATHmunging to Go 1.6 vendoring and ran into similar issues: moby/moby#29362They attempted to move the vendor directory under
cmdto work around this: moby/moby#28080. However, that approach has downsides, and it was abandoned.mtrmac commentedon Aug 8, 2020
With Go modules, which ignore the
vendorsubdirectories of libraries, being the default vendoring mechanism, this is no longer much of an issue.docker: reference: drop WithDigest to work with oci/go-digest
docker: reference: drop WithDigest to work with oci/go-digest