mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-05-29 08:57:44 +08:00
imagetools: support cross-repo mounting
Signed-off-by: Justin Chadwell <me@jedevc.com>
This commit is contained in:
parent
4ecca34a42
commit
f1a9f91323
@ -4,6 +4,8 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"net/url"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/containerd/containerd/content"
|
"github.com/containerd/containerd/content"
|
||||||
"github.com/containerd/containerd/errdefs"
|
"github.com/containerd/containerd/errdefs"
|
||||||
@ -183,6 +185,17 @@ func (r *Resolver) Copy(ctx context.Context, src *Source, dest reference.Named)
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
refspec := reference.TrimNamed(src.Ref).String()
|
||||||
|
u, err := url.Parse("dummy://" + refspec)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
source, repo := u.Hostname(), strings.TrimPrefix(u.Path, "/")
|
||||||
|
if src.Desc.Annotations == nil {
|
||||||
|
src.Desc.Annotations = make(map[string]string)
|
||||||
|
}
|
||||||
|
src.Desc.Annotations["containerd.io/distribution.source."+source] = repo
|
||||||
|
|
||||||
err = contentutil.CopyChain(ctx, contentutil.FromPusher(p), contentutil.FromFetcher(f), src.Desc)
|
err = contentutil.CopyChain(ctx, contentutil.FromPusher(p), contentutil.FromFetcher(f), src.Desc)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
Loading…
x
Reference in New Issue
Block a user