1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679
|
package manifests
import (
"encoding/json"
"errors"
"fmt"
"os"
"slices"
"strings"
"github.com/containers/common/internal"
"github.com/containers/image/v5/manifest"
digest "github.com/opencontainers/go-digest"
imgspec "github.com/opencontainers/image-spec/specs-go"
v1 "github.com/opencontainers/image-spec/specs-go/v1"
)
// List is a generic interface for manipulating a manifest list or an image
// index.
type List interface {
AddInstance(manifestDigest digest.Digest, manifestSize int64, manifestType, os, architecture, osVersion string, osFeatures []string, variant string, features []string, annotations []string) error
Remove(instanceDigest digest.Digest) error
SetURLs(instanceDigest digest.Digest, urls []string) error
URLs(instanceDigest digest.Digest) ([]string, error)
ClearAnnotations(instanceDigest *digest.Digest) error
SetAnnotations(instanceDigest *digest.Digest, annotations map[string]string) error
Annotations(instanceDigest *digest.Digest) (map[string]string, error)
SetOS(instanceDigest digest.Digest, os string) error
OS(instanceDigest digest.Digest) (string, error)
SetArchitecture(instanceDigest digest.Digest, arch string) error
Architecture(instanceDigest digest.Digest) (string, error)
SetOSVersion(instanceDigest digest.Digest, osVersion string) error
OSVersion(instanceDigest digest.Digest) (string, error)
SetVariant(instanceDigest digest.Digest, variant string) error
Variant(instanceDigest digest.Digest) (string, error)
SetFeatures(instanceDigest digest.Digest, features []string) error
Features(instanceDigest digest.Digest) ([]string, error)
SetOSFeatures(instanceDigest digest.Digest, osFeatures []string) error
OSFeatures(instanceDigest digest.Digest) ([]string, error)
SetMediaType(instanceDigest digest.Digest, mediaType string) error
MediaType(instanceDigest digest.Digest) (string, error)
SetArtifactType(instanceDigest *digest.Digest, artifactType string) error
ArtifactType(instanceDigest *digest.Digest) (string, error)
SetSubject(subject *v1.Descriptor) error
Subject() (*v1.Descriptor, error)
Serialize(mimeType string) ([]byte, error)
Instances() []digest.Digest
OCIv1() *v1.Index
Docker() *manifest.Schema2List
findDocker(instanceDigest digest.Digest) (*manifest.Schema2ManifestDescriptor, error)
findOCIv1(instanceDigest digest.Digest) (*v1.Descriptor, error)
}
type list struct {
docker manifest.Schema2List
oci v1.Index
}
// OCIv1 returns the list as a Docker schema 2 list. The returned structure should NOT be modified.
func (l *list) Docker() *manifest.Schema2List {
return &l.docker
}
// OCIv1 returns the list as an OCI image index. The returned structure should NOT be modified.
func (l *list) OCIv1() *v1.Index {
return &l.oci
}
// Create creates a new list.
func Create() List {
return &list{
docker: manifest.Schema2List{
SchemaVersion: 2,
MediaType: manifest.DockerV2ListMediaType,
},
oci: v1.Index{
Versioned: imgspec.Versioned{SchemaVersion: 2},
MediaType: v1.MediaTypeImageIndex,
},
}
}
func sliceToMap(s []string) map[string]string {
m := make(map[string]string, len(s))
for _, spec := range s {
key, value, _ := strings.Cut(spec, "=")
m[key] = value
}
return m
}
// AddInstance adds an entry for the specified manifest digest, with assorted
// additional information specified in parameters, to the list or index.
func (l *list) AddInstance(manifestDigest digest.Digest, manifestSize int64, manifestType, osName, architecture, osVersion string, osFeatures []string, variant string, features, annotations []string) error { // nolint:revive
if err := l.Remove(manifestDigest); err != nil && !errors.Is(err, os.ErrNotExist) {
return err
}
schema2platform := manifest.Schema2PlatformSpec{
Architecture: architecture,
OS: osName,
OSVersion: osVersion,
OSFeatures: osFeatures,
Variant: variant,
Features: features,
}
l.docker.Manifests = append(l.docker.Manifests, manifest.Schema2ManifestDescriptor{
Schema2Descriptor: manifest.Schema2Descriptor{
MediaType: manifestType,
Size: manifestSize,
Digest: manifestDigest,
},
Platform: schema2platform,
})
ociv1platform := &v1.Platform{
Architecture: architecture,
OS: osName,
OSVersion: osVersion,
OSFeatures: osFeatures,
Variant: variant,
}
if ociv1platform.Architecture == "" && ociv1platform.OS == "" && ociv1platform.OSVersion == "" && ociv1platform.Variant == "" && len(ociv1platform.OSFeatures) == 0 {
ociv1platform = nil
}
l.oci.Manifests = append(l.oci.Manifests, v1.Descriptor{
MediaType: manifestType,
Size: manifestSize,
Digest: manifestDigest,
Platform: ociv1platform,
Annotations: sliceToMap(annotations),
})
return nil
}
// Remove filters out any instances in the list which match the specified digest.
func (l *list) Remove(instanceDigest digest.Digest) error {
err := fmt.Errorf("no instance matching digest %q found in manifest list: %w", instanceDigest, os.ErrNotExist)
newDockerManifests := make([]manifest.Schema2ManifestDescriptor, 0, len(l.docker.Manifests))
for i := range l.docker.Manifests {
if l.docker.Manifests[i].Digest != instanceDigest {
newDockerManifests = append(newDockerManifests, l.docker.Manifests[i])
} else {
err = nil
}
}
l.docker.Manifests = newDockerManifests
newOCIv1Manifests := make([]v1.Descriptor, 0, len(l.oci.Manifests))
for i := range l.oci.Manifests {
if l.oci.Manifests[i].Digest != instanceDigest {
newOCIv1Manifests = append(newOCIv1Manifests, l.oci.Manifests[i])
} else {
err = nil
}
}
l.oci.Manifests = newOCIv1Manifests
return err
}
func (l *list) findDocker(instanceDigest digest.Digest) (*manifest.Schema2ManifestDescriptor, error) {
for i := range l.docker.Manifests {
if l.docker.Manifests[i].Digest == instanceDigest {
return &l.docker.Manifests[i], nil
}
}
return nil, fmt.Errorf("no Docker manifest matching digest %q was found in list: %w", instanceDigest.String(), ErrDigestNotFound)
}
func (l *list) findOCIv1(instanceDigest digest.Digest) (*v1.Descriptor, error) {
for i := range l.oci.Manifests {
if l.oci.Manifests[i].Digest == instanceDigest {
return &l.oci.Manifests[i], nil
}
}
return nil, fmt.Errorf("no OCI manifest matching digest %q was found in list: %w", instanceDigest.String(), ErrDigestNotFound)
}
// SetURLs sets the URLs where the manifest might also be found.
func (l *list) SetURLs(instanceDigest digest.Digest, urls []string) error {
oci, err := l.findOCIv1(instanceDigest)
if err != nil {
return err
}
docker, err := l.findDocker(instanceDigest)
if err != nil {
return err
}
oci.URLs = append([]string{}, urls...)
if len(oci.URLs) == 0 {
oci.URLs = nil
}
docker.URLs = append([]string{}, urls...)
if len(docker.URLs) == 0 {
docker.URLs = nil
}
return nil
}
// URLs retrieves the locations from which this object might possibly be downloaded.
func (l *list) URLs(instanceDigest digest.Digest) ([]string, error) {
oci, err := l.findOCIv1(instanceDigest)
if err != nil {
return nil, err
}
return append([]string{}, oci.URLs...), nil
}
// ClearAnnotations removes all annotations from the image index, or from a
// specific manifest.
// The field is specific to the OCI image index format, and is not present in Docker manifest lists.
func (l *list) ClearAnnotations(instanceDigest *digest.Digest) error {
a := &l.oci.Annotations
if instanceDigest != nil {
oci, err := l.findOCIv1(*instanceDigest)
if err != nil {
return err
}
a = &oci.Annotations
}
*a = nil
return nil
}
// SetAnnotations sets annotations on the image index, or on a specific
// manifest.
// The field is specific to the OCI image index format, and is not present in Docker manifest lists.
func (l *list) SetAnnotations(instanceDigest *digest.Digest, annotations map[string]string) error {
a := &l.oci.Annotations
if instanceDigest != nil {
oci, err := l.findOCIv1(*instanceDigest)
if err != nil {
return err
}
a = &oci.Annotations
}
if *a == nil {
(*a) = make(map[string]string)
}
for k, v := range annotations {
(*a)[k] = v
}
if len(*a) == 0 {
*a = nil
}
return nil
}
// Annotations retrieves the annotations which have been set on the image index, or on one instance.
// The field is specific to the OCI image index format, and is not present in Docker manifest lists.
func (l *list) Annotations(instanceDigest *digest.Digest) (map[string]string, error) {
a := l.oci.Annotations
if instanceDigest != nil {
oci, err := l.findOCIv1(*instanceDigest)
if err != nil {
return nil, err
}
a = oci.Annotations
}
annotations := make(map[string]string)
for k, v := range a {
annotations[k] = v
}
return annotations, nil
}
// SetOS sets the OS field in the platform information associated with the instance with the specified digest.
func (l *list) SetOS(instanceDigest digest.Digest, os string) error {
docker, err := l.findDocker(instanceDigest)
if err != nil {
return err
}
oci, err := l.findOCIv1(instanceDigest)
if err != nil {
return err
}
docker.Platform.OS = os
if oci.Platform == nil {
oci.Platform = &v1.Platform{}
}
oci.Platform.OS = os
if oci.Platform.Architecture == "" && oci.Platform.OS == "" && oci.Platform.OSVersion == "" && oci.Platform.Variant == "" && len(oci.Platform.OSFeatures) == 0 {
oci.Platform = nil
}
return nil
}
// OS retrieves the OS field in the platform information associated with the instance with the specified digest.
func (l *list) OS(instanceDigest digest.Digest) (string, error) {
oci, err := l.findOCIv1(instanceDigest)
if err != nil {
return "", err
}
platform := oci.Platform
if platform == nil {
platform = &v1.Platform{}
}
return platform.OS, nil
}
// SetArchitecture sets the Architecture field in the platform information associated with the instance with the specified digest.
func (l *list) SetArchitecture(instanceDigest digest.Digest, arch string) error {
docker, err := l.findDocker(instanceDigest)
if err != nil {
return err
}
oci, err := l.findOCIv1(instanceDigest)
if err != nil {
return err
}
docker.Platform.Architecture = arch
if oci.Platform == nil {
oci.Platform = &v1.Platform{}
}
oci.Platform.Architecture = arch
if oci.Platform.Architecture == "" && oci.Platform.OS == "" && oci.Platform.OSVersion == "" && oci.Platform.Variant == "" && len(oci.Platform.OSFeatures) == 0 {
oci.Platform = nil
}
return nil
}
// Architecture retrieves the Architecture field in the platform information associated with the instance with the specified digest.
func (l *list) Architecture(instanceDigest digest.Digest) (string, error) {
oci, err := l.findOCIv1(instanceDigest)
if err != nil {
return "", err
}
platform := oci.Platform
if platform == nil {
platform = &v1.Platform{}
}
return platform.Architecture, nil
}
// SetOSVersion sets the OSVersion field in the platform information associated with the instance with the specified digest.
func (l *list) SetOSVersion(instanceDigest digest.Digest, osVersion string) error {
docker, err := l.findDocker(instanceDigest)
if err != nil {
return err
}
oci, err := l.findOCIv1(instanceDigest)
if err != nil {
return err
}
docker.Platform.OSVersion = osVersion
if oci.Platform == nil {
oci.Platform = &v1.Platform{}
}
oci.Platform.OSVersion = osVersion
if oci.Platform.Architecture == "" && oci.Platform.OS == "" && oci.Platform.OSVersion == "" && oci.Platform.Variant == "" && len(oci.Platform.OSFeatures) == 0 {
oci.Platform = nil
}
return nil
}
// OSVersion retrieves the OSVersion field in the platform information associated with the instance with the specified digest.
func (l *list) OSVersion(instanceDigest digest.Digest) (string, error) {
oci, err := l.findOCIv1(instanceDigest)
if err != nil {
return "", err
}
platform := oci.Platform
if platform == nil {
platform = &v1.Platform{}
}
return platform.OSVersion, nil
}
// SetVariant sets the Variant field in the platform information associated with the instance with the specified digest.
func (l *list) SetVariant(instanceDigest digest.Digest, variant string) error {
docker, err := l.findDocker(instanceDigest)
if err != nil {
return err
}
oci, err := l.findOCIv1(instanceDigest)
if err != nil {
return err
}
docker.Platform.Variant = variant
if oci.Platform == nil {
oci.Platform = &v1.Platform{}
}
oci.Platform.Variant = variant
if oci.Platform.Architecture == "" && oci.Platform.OS == "" && oci.Platform.OSVersion == "" && oci.Platform.Variant == "" && len(oci.Platform.OSFeatures) == 0 {
oci.Platform = nil
}
return nil
}
// Variant retrieves the Variant field in the platform information associated with the instance with the specified digest.
func (l *list) Variant(instanceDigest digest.Digest) (string, error) {
oci, err := l.findOCIv1(instanceDigest)
if err != nil {
return "", err
}
platform := oci.Platform
if platform == nil {
platform = &v1.Platform{}
}
return platform.Variant, nil
}
// SetFeatures sets the features list in the platform information associated with the instance with the specified digest.
// The field is specific to the Docker manifest list format, and is not present in OCI's image indexes.
func (l *list) SetFeatures(instanceDigest digest.Digest, features []string) error {
docker, err := l.findDocker(instanceDigest)
if err != nil {
return err
}
docker.Platform.Features = append([]string{}, features...)
if len(docker.Platform.Features) == 0 {
docker.Platform.Features = nil
}
// no OCI equivalent
return nil
}
// Features retrieves the features list from the platform information associated with the instance with the specified digest.
// The field is specific to the Docker manifest list format, and is not present in OCI's image indexes.
func (l *list) Features(instanceDigest digest.Digest) ([]string, error) {
docker, err := l.findDocker(instanceDigest)
if err != nil {
return nil, err
}
return append([]string{}, docker.Platform.Features...), nil
}
// SetOSFeatures sets the OS features list in the platform information associated with the instance with the specified digest.
func (l *list) SetOSFeatures(instanceDigest digest.Digest, osFeatures []string) error {
docker, err := l.findDocker(instanceDigest)
if err != nil {
return err
}
oci, err := l.findOCIv1(instanceDigest)
if err != nil {
return err
}
docker.Platform.OSFeatures = append([]string{}, osFeatures...)
if oci.Platform == nil {
oci.Platform = &v1.Platform{}
}
oci.Platform.OSFeatures = append([]string{}, osFeatures...)
if len(oci.Platform.OSFeatures) == 0 {
oci.Platform.OSFeatures = nil
}
if oci.Platform.Architecture == "" && oci.Platform.OS == "" && oci.Platform.OSVersion == "" && oci.Platform.Variant == "" && len(oci.Platform.OSFeatures) == 0 {
oci.Platform = nil
}
return nil
}
// OSFeatures retrieves the OS features list from the platform information associated with the instance with the specified digest.
func (l *list) OSFeatures(instanceDigest digest.Digest) ([]string, error) {
oci, err := l.findOCIv1(instanceDigest)
if err != nil {
return nil, err
}
platform := oci.Platform
if platform == nil {
platform = &v1.Platform{}
}
return append([]string{}, platform.OSFeatures...), nil
}
// SetMediaType sets the MediaType field in the instance with the specified digest.
func (l *list) SetMediaType(instanceDigest digest.Digest, mediaType string) error {
oci, err := l.findOCIv1(instanceDigest)
if err != nil {
return err
}
oci.MediaType = mediaType
return nil
}
// MediaType retrieves the MediaType field in the instance with the specified digest.
func (l *list) MediaType(instanceDigest digest.Digest) (string, error) {
oci, err := l.findOCIv1(instanceDigest)
if err != nil {
return "", err
}
return oci.MediaType, nil
}
// SetArtifactType sets the ArtifactType field in the instance with the specified digest.
func (l *list) SetArtifactType(instanceDigest *digest.Digest, artifactType string) error {
artifactTypePtr := &l.oci.ArtifactType
if instanceDigest != nil {
oci, err := l.findOCIv1(*instanceDigest)
if err != nil {
return err
}
artifactTypePtr = &oci.ArtifactType
}
*artifactTypePtr = artifactType
return nil
}
// ArtifactType retrieves the ArtifactType field in the instance with the specified digest.
func (l *list) ArtifactType(instanceDigest *digest.Digest) (string, error) {
artifactTypePtr := &l.oci.ArtifactType
if instanceDigest != nil {
oci, err := l.findOCIv1(*instanceDigest)
if err != nil {
return "", err
}
artifactTypePtr = &oci.ArtifactType
}
return *artifactTypePtr, nil
}
// SetSubject sets the image index's subject.
// The field is specific to the OCI image index format, and is not present in Docker manifest lists.
func (l *list) SetSubject(subject *v1.Descriptor) error {
if subject != nil {
subject = internal.DeepCopyDescriptor(subject)
}
l.oci.Subject = subject
return nil
}
// Subject retrieves the subject which might have been set on the image index.
// The field is specific to the OCI image index format, and is not present in Docker manifest lists.
func (l *list) Subject() (*v1.Descriptor, error) {
s := l.oci.Subject
if s != nil {
s = internal.DeepCopyDescriptor(s)
}
return s, nil
}
// FromBlob builds a list from an encoded manifest list or image index.
func FromBlob(manifestBytes []byte) (List, error) {
manifestType := manifest.GuessMIMEType(manifestBytes)
list := &list{
docker: manifest.Schema2List{
SchemaVersion: 2,
MediaType: manifest.DockerV2ListMediaType,
},
oci: v1.Index{
Versioned: imgspec.Versioned{SchemaVersion: 2},
MediaType: v1.MediaTypeImageIndex,
},
}
switch manifestType {
default:
return nil, fmt.Errorf("unable to load manifest list: unsupported format %q: %w", manifestType, ErrManifestTypeNotSupported)
case manifest.DockerV2ListMediaType:
if err := json.Unmarshal(manifestBytes, &list.docker); err != nil {
return nil, fmt.Errorf("unable to parse Docker manifest list from image: %w", err)
}
for _, m := range list.docker.Manifests {
list.oci.Manifests = append(list.oci.Manifests, v1.Descriptor{
MediaType: m.Schema2Descriptor.MediaType,
Size: m.Schema2Descriptor.Size,
Digest: m.Schema2Descriptor.Digest,
Platform: &v1.Platform{
Architecture: m.Platform.Architecture,
OS: m.Platform.OS,
OSVersion: m.Platform.OSVersion,
OSFeatures: m.Platform.OSFeatures,
Variant: m.Platform.Variant,
},
})
}
case v1.MediaTypeImageIndex:
if err := json.Unmarshal(manifestBytes, &list.oci); err != nil {
return nil, fmt.Errorf("unable to parse OCIv1 manifest list: %w", err)
}
for _, m := range list.oci.Manifests {
platform := m.Platform
if platform == nil {
platform = &v1.Platform{}
}
if m.Platform != nil && m.Platform.OSFeatures != nil {
platform.OSFeatures = slices.Clone(m.Platform.OSFeatures)
}
var urls []string
if m.URLs != nil {
urls = slices.Clone(m.URLs)
}
list.docker.Manifests = append(list.docker.Manifests, manifest.Schema2ManifestDescriptor{
Schema2Descriptor: manifest.Schema2Descriptor{
MediaType: m.MediaType,
Size: m.Size,
Digest: m.Digest,
URLs: urls,
},
Platform: manifest.Schema2PlatformSpec{
Architecture: platform.Architecture,
OS: platform.OS,
OSVersion: platform.OSVersion,
OSFeatures: platform.OSFeatures,
Variant: platform.Variant,
},
})
}
}
return list, nil
}
func (l *list) preferOCI() bool {
// If we have any data that's only in the OCI format, use that.
if l.oci.ArtifactType != "" {
return true
}
if l.oci.Subject != nil {
return true
}
if len(l.oci.Annotations) > 0 {
return true
}
for _, m := range l.oci.Manifests {
if m.ArtifactType != "" {
return true
}
if len(m.Annotations) > 0 {
return true
}
if len(m.Data) > 0 {
return true
}
}
// If we have any data that's only in the Docker format, use that.
for _, m := range l.docker.Manifests {
if len(m.Platform.Features) > 0 {
return false
}
}
// If we have no manifests, remember that the Docker format is
// explicitly typed, so use that. Otherwise, default to using the OCI
// format.
return len(l.docker.Manifests) != 0
}
// Serialize encodes the list using the specified format, or by selecting one
// which it thinks is appropriate.
func (l *list) Serialize(mimeType string) ([]byte, error) {
var (
res []byte
err error
)
switch mimeType {
case "":
if l.preferOCI() {
res, err = json.Marshal(&l.oci)
if err != nil {
return nil, fmt.Errorf("marshalling OCI image index: %w", err)
}
} else {
res, err = json.Marshal(&l.docker)
if err != nil {
return nil, fmt.Errorf("marshalling Docker manifest list: %w", err)
}
}
case v1.MediaTypeImageIndex:
res, err = json.Marshal(&l.oci)
if err != nil {
return nil, fmt.Errorf("marshalling OCI image index: %w", err)
}
case manifest.DockerV2ListMediaType:
res, err = json.Marshal(&l.docker)
if err != nil {
return nil, fmt.Errorf("marshalling Docker manifest list: %w", err)
}
default:
return nil, fmt.Errorf("serializing list to type %q not implemented: %w", mimeType, ErrManifestTypeNotSupported)
}
return res, nil
}
// Instances returns the list of image instances mentioned in this list.
func (l *list) Instances() []digest.Digest {
instances := make([]digest.Digest, 0, len(l.oci.Manifests))
for _, instance := range l.oci.Manifests {
instances = append(instances, instance.Digest)
}
return instances
}
|