Merge pull request #182 from runcom/fix-oci

vendor containers/image for oci dest fix
This commit is contained in:
Antonio Murdaca 2016-09-01 18:01:44 +02:00 committed by GitHub
commit 1bfb549f7f
2 changed files with 15 additions and 4 deletions

View File

@ -96,7 +96,11 @@ func (d *ociImageDestination) PutManifest(m []byte) error {
return err
}
if err := ioutil.WriteFile(d.ref.blobPath(digest), ociMan, 0644); err != nil {
blobPath, err := d.ref.blobPath(digest)
if err != nil {
return err
}
if err := ioutil.WriteFile(blobPath, ociMan, 0644); err != nil {
return err
}
// TODO(runcom): ugly here?
@ -116,7 +120,10 @@ func (d *ociImageDestination) PutManifest(m []byte) error {
// If stream.Read() at any time, ESPECIALLY at end of input, returns an error, PutBlob MUST 1) fail, and 2) delete any data stored so far.
// Note: Calling PutBlob() and other methods may have ordering dependencies WRT other methods of this type. FIXME: Figure out and document.
func (d *ociImageDestination) PutBlob(digest string, stream io.Reader) error {
blobPath := d.ref.blobPath(digest)
blobPath, err := d.ref.blobPath(digest)
if err != nil {
return err
}
if err := ensureParentDirectoryExists(blobPath); err != nil {
return err
}

View File

@ -192,8 +192,12 @@ func (ref ociReference) ociLayoutPath() string {
}
// blobPath returns a path for a blob within a directory using OCI image-layout conventions.
func (ref ociReference) blobPath(digest string) string {
return filepath.Join(ref.dir, "blobs", strings.Replace(digest, ":", "-", -1))
func (ref ociReference) blobPath(digest string) (string, error) {
pts := strings.SplitN(digest, ":", 2)
if len(pts) != 2 {
return "", fmt.Errorf("unexpected digest reference %s", digest)
}
return filepath.Join(ref.dir, "blobs", pts[0], pts[1]), nil
}
// descriptorPath returns a path for the manifest within a directory using OCI conventions.