Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions client/oci.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ func (c *Client) ociRegistryAuth(ctx context.Context, name string, accessTypes [
v := url.Values{}
v.Set("namespace", name)

// Setting 'mapped' to '1' (true) enables support for mapping short library refs to
// fully-qualified name
v.Set("mapped", strconv.Itoa(1))

ats := make([]string, 0, len(accessTypes))
for _, at := range accessTypes {
ats = append(ats, string(at))
Expand Down Expand Up @@ -630,6 +634,7 @@ func (r *ociRegistry) getImageConfig(ctx context.Context, creds credentials, nam

var errOCIDownloadNotSupported = errors.New("not supported")

// newOCIRegistry returns *ociRegistry, credentials for that registry, and the (optionally) remapped image name
func (c *Client) newOCIRegistry(ctx context.Context, name string, accessTypes []accessType) (*ociRegistry, *bearerTokenCredentials, string, error) {
// Attempt to obtain (direct) OCI registry auth token
originalName := name
Expand Down
17 changes: 9 additions & 8 deletions client/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,16 +158,17 @@ func (c *Client) ConcurrentDownloadImage(ctx context.Context, dst *os.File, arch
}

// Check for direct OCI registry access
if err := c.ociDownloadImage(ctx, arch, name, tag, dst, spec, pb); err == nil {
return err
} else if !errors.Is(err, errOCIDownloadNotSupported) {
// Return OCI download error or fallback to legacy download
return err
}
if err := c.ociDownloadImage(ctx, arch, name, tag, dst, spec, pb); err != nil {
if !errors.Is(err, errOCIDownloadNotSupported) {
// Return OCI download error or fallback to legacy download
return err
}

c.Logger.Log("Fallback to (legacy) library download")
c.Logger.Log("Fallback to (legacy) library download")

return c.legacyDownloadImage(ctx, arch, name, tag, dst, spec, pb)
return c.legacyDownloadImage(ctx, arch, name, tag, dst, spec, pb)
}
return nil
}

func (c *Client) legacyDownloadImage(ctx context.Context, arch, name, tag string, dst io.WriterAt, spec *Downloader, pb ProgressBar) error {
Expand Down
2 changes: 1 addition & 1 deletion client/pull_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ func seedRandomNumberGenerator(t *testing.T) {
if _, err := crypto_rand.Read(b[:]); err != nil {
t.Fatalf("error seeding random number generator: %v", err)
}
math_rand.Seed(int64(binary.LittleEndian.Uint64(b[:])))
math_rand.New(math_rand.NewSource(int64(binary.LittleEndian.Uint64(b[:]))))
}

// mockLibraryServer returns *httptest.Server that mocks Cloud Library server; in particular,
Expand Down