Skip to content

Commit

Permalink
imagetools: support cross-repo mounting
Browse files Browse the repository at this point in the history
This relies on new functionality in buildkit, and pulls it by:

    $ go get -u github.com/moby/buildkit@5d68aa5b6e90a8c15e0364edb8f144e1215a9f94
    $ go mod tidy -compat=1.17
    $ make vendor

Signed-off-by: Justin Chadwell <[email protected]>
  • Loading branch information
jedevc committed Jun 7, 2022
1 parent 5ead154 commit 26d9f7a
Show file tree
Hide file tree
Showing 7 changed files with 105 additions and 18 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ require (
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510
github.com/hashicorp/go-cty-funcs v0.0.0-20200930094925-2721b1e36840
github.com/hashicorp/hcl/v2 v2.8.2
github.com/moby/buildkit v0.10.1-0.20220513101920-55f0ecfdafaa
github.com/moby/buildkit v0.10.1-0.20220526231503-5d68aa5b6e90
github.com/morikuni/aec v1.0.0
github.com/opencontainers/go-digest v1.0.0
github.com/opencontainers/image-spec v1.0.3-0.20211202183452-c5a74bcca799
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -457,8 +457,8 @@ github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RR
github.com/mitchellh/mapstructure v1.4.3 h1:OVowDSCllw/YjdLkam3/sm7wEtOy59d8ndGgCcyj8cs=
github.com/mitchellh/mapstructure v1.4.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
github.com/mitchellh/osext v0.0.0-20151018003038-5e2d6d41470f/go.mod h1:OkQIRizQZAeMln+1tSwduZz7+Af5oFlKirV/MSYes2A=
github.com/moby/buildkit v0.10.1-0.20220513101920-55f0ecfdafaa h1:Q8d1P3Ot+Z0eoynWkiWAfSyXRkvzPXqvUjE5y/Ycxw4=
github.com/moby/buildkit v0.10.1-0.20220513101920-55f0ecfdafaa/go.mod h1:grddVHNUy3u8m1v5ZEbFKhpIwyGmLsSd8rRwJ5ccg7c=
github.com/moby/buildkit v0.10.1-0.20220526231503-5d68aa5b6e90 h1:BxgfFwr39x0aBaTnUQ6jw8XzBMaaKHaGJhdpOQ2M9VA=
github.com/moby/buildkit v0.10.1-0.20220526231503-5d68aa5b6e90/go.mod h1:1wjDnnBLPyJXed4jRdMT8kC8MF4Myb9ZzgboWqMVXeE=
github.com/moby/locker v1.0.1 h1:fOXqR41zeveg4fFODix+1Ch4mj/gT0NE1XJbp/epuBg=
github.com/moby/locker v1.0.1/go.mod h1:S7SDdo5zpBK84bzzVlKr2V0hz+7x9hWbYC/kq7oQppc=
github.com/moby/spdystream v0.2.0 h1:cjW1zVyyoiM0T7b6UoySUFqzXMoqRckQtXwGPiBhOM8=
Expand Down
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

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions vendor/github.com/moby/buildkit/solver/pb/caps.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 44 additions & 1 deletion vendor/github.com/moby/buildkit/util/contentutil/copy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ github.com/mitchellh/go-wordwrap
# github.com/mitchellh/mapstructure v1.4.3
## explicit; go 1.14
github.com/mitchellh/mapstructure
# github.com/moby/buildkit v0.10.1-0.20220513101920-55f0ecfdafaa
# github.com/moby/buildkit v0.10.1-0.20220526231503-5d68aa5b6e90
## explicit; go 1.17
github.com/moby/buildkit/api/services/control
github.com/moby/buildkit/api/types
Expand Down

0 comments on commit 26d9f7a

Please sign in to comment.