mirror of
https://github.com/genuinetools/reg.git
synced 2024-05-20 12:08:33 -04:00
put manifest
Signed-off-by: Vadim Bauer <bauer.vadim@gmail.com>
This commit is contained in:
parent
8dba69bce4
commit
720e7deac5
|
@ -8,6 +8,8 @@ import (
|
|||
"github.com/docker/distribution/manifest/manifestlist"
|
||||
"github.com/docker/distribution/manifest/schema1"
|
||||
"github.com/docker/distribution/manifest/schema2"
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
// Manifest returns the manifest for a specific repository:tag.
|
||||
|
@ -84,3 +86,27 @@ func (r *Registry) ManifestV1(repository, ref string) (schema1.SignedManifest, e
|
|||
|
||||
return m, nil
|
||||
}
|
||||
|
||||
|
||||
func (r *Registry) PutManifest(repository, reference string, manifest distribution.Manifest) error {
|
||||
url := r.url("/v2/%s/manifests/%s", repository, reference)
|
||||
r.Logf("registry.manifest.put url=%s repository=%s reference=%s", url, repository, reference)
|
||||
|
||||
manifestJson, err := json.Marshal(manifest)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
buffer := bytes.NewBuffer(manifestJson)
|
||||
req, err := http.NewRequest("PUT", url, buffer)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
req.Header.Set("Content-Type", schema2.MediaTypeManifest)
|
||||
resp, err := r.Client.Do(req)
|
||||
if resp != nil {
|
||||
defer resp.Body.Close()
|
||||
}
|
||||
return err
|
||||
}
|
Loading…
Reference in a new issue