Skip to content

Commit

Permalink
imagetools: support cross-repo mounting
Browse files Browse the repository at this point in the history
Signed-off-by: Justin Chadwell <[email protected]>
  • Loading branch information
jedevc committed Jul 20, 2022
1 parent 6b70c02 commit 0602be0
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions util/imagetools/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"bytes"
"context"
"encoding/json"
"net/url"
"strings"

"github.com/containerd/containerd/content"
"github.com/containerd/containerd/errdefs"
Expand Down Expand Up @@ -183,6 +185,17 @@ func (r *Resolver) Copy(ctx context.Context, src *Source, dest reference.Named)
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)
if err != nil {
return err
Expand Down

0 comments on commit 0602be0

Please sign in to comment.