repocli: first version of pull & push image

This commit is contained in:
2026-03-10 21:19:19 +02:00
parent f85cda868a
commit 9bc3b77144
13 changed files with 61 additions and 90 deletions
+5 -5
View File
@@ -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
}