mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-07-09 21:17:09 +08:00
imagetools: push support for create
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
@ -1,10 +1,13 @@
|
||||
package imagetools
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
|
||||
"github.com/containerd/containerd/content"
|
||||
"github.com/containerd/containerd/images"
|
||||
"github.com/docker/distribution/reference"
|
||||
"github.com/opencontainers/go-digest"
|
||||
"github.com/opencontainers/image-spec/specs-go"
|
||||
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
|
||||
}
|
||||
|
||||
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) {
|
||||
var manifest ocispec.Manifest
|
||||
if err := json.Unmarshal(dt, &manifest); err != nil {
|
||||
|
Reference in New Issue
Block a user