...

Source file src/edge-infra.dev/pkg/f8n/warehouse/pallet/index.go

Documentation: edge-infra.dev/pkg/f8n/warehouse/pallet

     1  package pallet
     2  
     3  import (
     4  	"fmt"
     5  
     6  	v1 "github.com/google/go-containerregistry/pkg/v1"
     7  	"github.com/google/go-containerregistry/pkg/v1/empty"
     8  	gmutate "github.com/google/go-containerregistry/pkg/v1/mutate"
     9  	"github.com/google/go-containerregistry/pkg/v1/types"
    10  
    11  	"edge-infra.dev/pkg/f8n/warehouse/oci"
    12  	"edge-infra.dev/pkg/f8n/warehouse/oci/mutate"
    13  )
    14  
    15  // ImageIndex creates a new Pallet that is an OCI v1.ImageIndex
    16  func ImageIndex(o Options, artifacts ...oci.Artifact) (Pallet, error) {
    17  	if len(artifacts) == 0 {
    18  		return nil, fmt.Errorf("pallet.ImageIndex: no artifacts provided")
    19  	}
    20  
    21  	p, err := fromOpts(o)
    22  	if err != nil {
    23  		return nil, err
    24  	}
    25  
    26  	idx, err := mutate.AppendManifests(empty.Index, artifacts...)
    27  	if err != nil {
    28  		return nil, fmt.Errorf("pallet.ImageIndex: %w", err)
    29  	}
    30  
    31  	p.Artifact = gmutate.IndexMediaType(
    32  		oci.Annotate(idx, o.annos()...).(v1.ImageIndex), types.OCIImageIndex,
    33  	).(oci.Artifact)
    34  
    35  	return p, nil
    36  }
    37  

View as plain text