fetch: Use data from descriptor when available.
OCI added support for a `data` field in a descriptor. This field is expected to contain the content being pointed to by the descriptor. Signed-off-by: Brian Goff <cpuguy83@gmail.com>
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
package remotes
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
@@ -139,6 +140,10 @@ func Fetch(ctx context.Context, ingester content.Ingester, fetcher Fetcher, desc
|
||||
return err
|
||||
}
|
||||
|
||||
if desc.Size == int64(len(desc.Data)) {
|
||||
return content.Copy(ctx, cw, bytes.NewReader(desc.Data), desc.Size, desc.Digest)
|
||||
}
|
||||
|
||||
rc, err := fetcher.Fetch(ctx, desc)
|
||||
if err != nil {
|
||||
return err
|
||||
|
Reference in New Issue
Block a user