diff --git a/api/oci/extensions/repositories/ocireg/repository.go b/api/oci/extensions/repositories/ocireg/repository.go index 8d31108465..4203284939 100644 --- a/api/oci/extensions/repositories/ocireg/repository.go +++ b/api/oci/extensions/repositories/ocireg/repository.go @@ -121,16 +121,23 @@ func (r *RepositoryImpl) getResolver(comp string) (regclient.Resolver, error) { logger.Trace("no credentials") } - pass := creds.GetProperty(credentials.ATTR_IDENTITY_TOKEN) - if pass == "" { - pass = creds.GetProperty(credentials.ATTR_PASSWORD) + var ( + password, username string + ) + + if creds != nil { + password = creds.GetProperty(credentials.ATTR_IDENTITY_TOKEN) + if password == "" { + password = creds.GetProperty(credentials.ATTR_PASSWORD) + } + username = creds.GetProperty(credentials.ATTR_USERNAME) } - username := creds.GetProperty(credentials.ATTR_USERNAME) + opts := regclient.ClientOptions{ Host: ®config.Host{ - Name: "ghcr.io", + Name: "ghcr.io", //TODO: Need to figure out how to set the host. User: username, - Pass: pass, + Pass: password, }, Version: comp, } diff --git a/api/tech/regclient/client.go b/api/tech/regclient/client.go index f709b05c23..f4302d0d08 100644 --- a/api/tech/regclient/client.go +++ b/api/tech/regclient/client.go @@ -141,16 +141,15 @@ func (c *Client) Resolve(ctx context.Context, ref string) (string, ociv1.Descrip if strings.Contains(err.Error(), "not found") { // fallback to finding a blob if we have a digest if r.Digest != "" { - blob, err := c.rc.BlobHead(ctx, r, descriptor.Descriptor{ + blob, err := c.rc.BlobGet(ctx, r, descriptor.Descriptor{ Digest: digest.Digest(r.Digest), - Size: -1, }) if err != nil { if strings.Contains(err.Error(), "not found") { return "", ociv1.Descriptor{}, errdefs.ErrNotFound } - return "", ociv1.Descriptor{}, err + return "", ociv1.Descriptor{}, fmt.Errorf("failed to resolve blob head: %w", err) } return ref, c.convertDescriptorToOCI(blob.GetDescriptor()), nil @@ -196,6 +195,7 @@ func (c *Client) Lister(ctx context.Context, ref string) (Lister, error) { } func (c *Client) Push(ctx context.Context, d ociv1.Descriptor, src Source) (PushRequest, error) { + fmt.Println("IN FUCKING PUSH: ", d) reader, err := src.Reader() if err != nil { return nil, err @@ -249,9 +249,13 @@ func (c *Client) Fetch(ctx context.Context, desc ociv1.Descriptor) (_ io.ReadClo }() // set up closing the client after fetching is done. + // -1 is not a thing in regclient. + if desc.Size < 0 { + desc.Size = 0 + } reader, err := c.rc.BlobGet(ctx, c.ref, c.convertDescriptorToRegClient(desc)) if err != nil { - return nil, err + return nil, fmt.Errorf("failed to get the blob reader: %w", err) } return reader, nil