-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #618 from tonistiigi/test-local
integration: use local registry mirrors
- Loading branch information
Showing
7 changed files
with
293 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package contentutil | ||
|
||
import ( | ||
"context" | ||
"net/http" | ||
|
||
"github.com/containerd/containerd/content" | ||
"github.com/containerd/containerd/remotes" | ||
"github.com/containerd/containerd/remotes/docker" | ||
ocispec "github.com/opencontainers/image-spec/specs-go/v1" | ||
) | ||
|
||
func ProviderFromRef(ref string) (ocispec.Descriptor, content.Provider, error) { | ||
remote := docker.NewResolver(docker.ResolverOptions{ | ||
Client: http.DefaultClient, | ||
}) | ||
|
||
name, desc, err := remote.Resolve(context.TODO(), ref) | ||
if err != nil { | ||
return ocispec.Descriptor{}, nil, err | ||
} | ||
|
||
fetcher, err := remote.Fetcher(context.TODO(), name) | ||
if err != nil { | ||
return ocispec.Descriptor{}, nil, err | ||
} | ||
return desc, FromFetcher(fetcher), nil | ||
} | ||
|
||
func IngesterFromRef(ref string) (content.Ingester, error) { | ||
remote := docker.NewResolver(docker.ResolverOptions{ | ||
Client: http.DefaultClient, | ||
}) | ||
|
||
pusher, err := remote.Pusher(context.TODO(), ref) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return &ingester{ | ||
pusher: pusher, | ||
}, nil | ||
} | ||
|
||
type ingester struct { | ||
pusher remotes.Pusher | ||
} | ||
|
||
func (w *ingester) Writer(ctx context.Context, opts ...content.WriterOpt) (content.Writer, error) { | ||
var wo content.WriterOpts | ||
for _, o := range opts { | ||
if err := o(&wo); err != nil { | ||
return nil, err | ||
} | ||
} | ||
return w.pusher.Push(ctx, wo.Desc) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.