daemon/c8d: use new containerd LabelDistributionSource constant
Introduced in dd3eedf3c3
Signed-off-by: Bjorn Neergaard <bjorn.neergaard@docker.com>
This commit is contained in:
parent
fd6dd6935b
commit
8cd5f04ea3
2 changed files with 6 additions and 8 deletions
|
@ -13,6 +13,7 @@ import (
|
|||
cerrdefs "github.com/containerd/containerd/errdefs"
|
||||
"github.com/containerd/containerd/images"
|
||||
containerdimages "github.com/containerd/containerd/images"
|
||||
containerdlabels "github.com/containerd/containerd/labels"
|
||||
"github.com/containerd/containerd/log"
|
||||
"github.com/containerd/containerd/platforms"
|
||||
"github.com/containerd/containerd/remotes"
|
||||
|
@ -246,23 +247,19 @@ func getDigestSources(ctx context.Context, store content.Manager, digest digest.
|
|||
|
||||
sources := extractDistributionSources(info.Labels)
|
||||
if sources == nil {
|
||||
return nil, errdefs.NotFound(fmt.Errorf("label %q is not attached to %s", labelDistributionSource, digest.String()))
|
||||
return nil, errdefs.NotFound(fmt.Errorf("label %q is not attached to %s", containerdlabels.LabelDistributionSource, digest.String()))
|
||||
}
|
||||
|
||||
return sources, nil
|
||||
}
|
||||
|
||||
// TODO(vvoland): Remove and use containerd const in containerd 1.7+
|
||||
// https://github.com/containerd/containerd/pull/8224
|
||||
const labelDistributionSource = "containerd.io/distribution.source."
|
||||
|
||||
func extractDistributionSources(labels map[string]string) []distributionSource {
|
||||
var sources []distributionSource
|
||||
|
||||
// Check if this blob has a distributionSource label
|
||||
// if yes, read it as source
|
||||
for k, v := range labels {
|
||||
if reg := strings.TrimPrefix(k, labelDistributionSource); reg != k {
|
||||
if reg := strings.TrimPrefix(k, containerdlabels.LabelDistributionSource); reg != k {
|
||||
for _, repo := range strings.Split(v, ",") {
|
||||
ref, err := reference.ParseNamed(reg + "/" + repo)
|
||||
if err != nil {
|
||||
|
@ -287,7 +284,7 @@ type distributionSource struct {
|
|||
func (source distributionSource) ToAnnotation() (string, string) {
|
||||
domain := reference.Domain(source.registryRef)
|
||||
v := reference.Path(source.registryRef)
|
||||
return labelDistributionSource + domain, v
|
||||
return containerdlabels.LabelDistributionSource + domain, v
|
||||
}
|
||||
|
||||
func (source distributionSource) GetReference(dgst digest.Digest) (reference.Named, error) {
|
||||
|
|
|
@ -5,6 +5,7 @@ import (
|
|||
|
||||
"github.com/containerd/containerd/content"
|
||||
cerrdefs "github.com/containerd/containerd/errdefs"
|
||||
containerdlabels "github.com/containerd/containerd/labels"
|
||||
"github.com/distribution/reference"
|
||||
"github.com/opencontainers/go-digest"
|
||||
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
|
@ -42,7 +43,7 @@ func (p fakeStoreWithSources) Info(ctx context.Context, dgst digest.Digest) (con
|
|||
return info, err
|
||||
}
|
||||
|
||||
key := labelDistributionSource + reference.Domain(source.registryRef)
|
||||
key := containerdlabels.LabelDistributionSource + reference.Domain(source.registryRef)
|
||||
value := reference.Path(source.registryRef)
|
||||
return content.Info{
|
||||
Digest: dgst,
|
||||
|
|
Loading…
Add table
Reference in a new issue