mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-07-10 05:27:07 +08:00
imagetools: push support for create
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
@ -137,10 +137,22 @@ func runCreate(dockerCli command.Cli, in createOptions, args []string) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
_ = desc
|
|
||||||
|
|
||||||
if in.dryrun {
|
if in.dryrun {
|
||||||
fmt.Printf("%s\n", dt)
|
fmt.Printf("%s\n", dt)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// new resolver cause need new auth
|
||||||
|
r = imagetools.New(imagetools.Opt{
|
||||||
|
Auth: dockerCli.ConfigFile(),
|
||||||
|
})
|
||||||
|
|
||||||
|
for _, t := range tags {
|
||||||
|
if err := r.Push(ctx, t, desc, dt); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
fmt.Println(t.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
@ -1,10 +1,13 @@
|
|||||||
package imagetools
|
package imagetools
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
|
"github.com/containerd/containerd/content"
|
||||||
"github.com/containerd/containerd/images"
|
"github.com/containerd/containerd/images"
|
||||||
|
"github.com/docker/distribution/reference"
|
||||||
"github.com/opencontainers/go-digest"
|
"github.com/opencontainers/go-digest"
|
||||||
"github.com/opencontainers/image-spec/specs-go"
|
"github.com/opencontainers/image-spec/specs-go"
|
||||||
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||||
@ -142,6 +145,19 @@ func (r *Resolver) Combine(ctx context.Context, in string, descs []ocispec.Descr
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (r *Resolver) Push(ctx context.Context, ref reference.Named, desc ocispec.Descriptor, dt []byte) error {
|
||||||
|
p, err := r.r.Pusher(ctx, ref.String())
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
cw, err := p.Push(ctx, desc)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return content.Copy(ctx, cw, bytes.NewReader(dt), desc.Size, desc.Digest)
|
||||||
|
}
|
||||||
|
|
||||||
func (r *Resolver) loadConfig(ctx context.Context, in string, dt []byte) (*ocispec.Image, error) {
|
func (r *Resolver) loadConfig(ctx context.Context, in string, dt []byte) (*ocispec.Image, error) {
|
||||||
var manifest ocispec.Manifest
|
var manifest ocispec.Manifest
|
||||||
if err := json.Unmarshal(dt, &manifest); err != nil {
|
if err := json.Unmarshal(dt, &manifest); err != nil {
|
||||||
|
2
vendor/modules.txt
vendored
2
vendor/modules.txt
vendored
@ -29,11 +29,11 @@ github.com/containerd/console
|
|||||||
# github.com/containerd/containerd v1.3.0-0.20190321141026-ceba56893a76
|
# github.com/containerd/containerd v1.3.0-0.20190321141026-ceba56893a76
|
||||||
github.com/containerd/containerd/platforms
|
github.com/containerd/containerd/platforms
|
||||||
github.com/containerd/containerd/images
|
github.com/containerd/containerd/images
|
||||||
|
github.com/containerd/containerd/content
|
||||||
github.com/containerd/containerd/remotes
|
github.com/containerd/containerd/remotes
|
||||||
github.com/containerd/containerd/remotes/docker
|
github.com/containerd/containerd/remotes/docker
|
||||||
github.com/containerd/containerd/errdefs
|
github.com/containerd/containerd/errdefs
|
||||||
github.com/containerd/containerd/log
|
github.com/containerd/containerd/log
|
||||||
github.com/containerd/containerd/content
|
|
||||||
github.com/containerd/containerd/content/local
|
github.com/containerd/containerd/content/local
|
||||||
github.com/containerd/containerd/labels
|
github.com/containerd/containerd/labels
|
||||||
github.com/containerd/containerd/reference
|
github.com/containerd/containerd/reference
|
||||||
|
Reference in New Issue
Block a user