repocli: first version of pull & push image
This commit is contained in:
@@ -9,17 +9,17 @@ import (
|
||||
ocidigest "github.com/opencontainers/go-digest"
|
||||
)
|
||||
|
||||
func (cli *Client) PutManifest(ctx context.Context, rawrepo, tag string, man []byte, mime string) error {
|
||||
func (cli *Client) PutManifest(ctx context.Context, rawref string, man []byte, mime string) error {
|
||||
var err error
|
||||
|
||||
ref, err := NewReferer(rawrepo)
|
||||
ref, err := NewReferer(rawref)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
uri := ref.ManifestEP()
|
||||
|
||||
buffer := bytes.NewBuffer(man)
|
||||
req, err := http.NewRequestWithContext(ctx, http.MethodPut, uri, buffer)
|
||||
reader := bytes.NewReader(man)
|
||||
req, err := http.NewRequestWithContext(ctx, http.MethodPut, uri, reader)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -33,7 +33,7 @@ func (cli *Client) PutManifest(ctx context.Context, rawrepo, tag string, man []b
|
||||
return err
|
||||
}
|
||||
resp.Body.Close()
|
||||
if resp.StatusCode != http.StatusAccepted {
|
||||
if resp.StatusCode != http.StatusAccepted && resp.StatusCode != http.StatusCreated {
|
||||
err = fmt.Errorf("Manifest not accepted, code %d", resp.StatusCode)
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user