descriptor

package
v0.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 24, 2024 License: Apache-2.0 Imports: 11 Imported by: 1

Documentation

Overview

Package descriptor defines the OCI descriptor data structure used in manifests to reference content addressable data.

Index

Constants

This section is empty.

Variables

View Source
var (
	// EmptyData is the content of the empty JSON descriptor. See [mediatype.OCI1Empty].
	EmptyData = []byte("{}")
	// EmptyDigest is the digest of the empty JSON descriptor. See [mediatype.OCI1Empty].
	EmptyDigest = digest.FromBytes(EmptyData)
)

Functions

This section is empty.

Types

type Descriptor

type Descriptor struct {
	// MediaType describe the type of the content.
	MediaType string `json:"mediaType"`

	// Digest uniquely identifies the content.
	Digest digest.Digest `json:"digest"`

	// Size in bytes of content.
	Size int64 `json:"size"`

	// URLs contains the source URLs of this content.
	URLs []string `json:"urls,omitempty"`

	// Annotations contains arbitrary metadata relating to the targeted content.
	Annotations map[string]string `json:"annotations,omitempty"`

	// Data is an embedding of the targeted content. This is encoded as a base64
	// string when marshalled to JSON (automatically, by encoding/json). If
	// present, Data can be used directly to avoid fetching the targeted content.
	Data []byte `json:"data,omitempty"`

	// Platform describes the platform which the image in the manifest runs on.
	// This should only be used when referring to a manifest.
	Platform *platform.Platform `json:"platform,omitempty"`

	// ArtifactType is the media type of the artifact this descriptor refers to.
	ArtifactType string `json:"artifactType,omitempty"`
}

Descriptor is used in manifests to refer to content by media type, size, and digest.

func DescriptorListFilter

func DescriptorListFilter(dl []Descriptor, opt MatchOpt) []Descriptor

DescriptorListFilter returns a list of descriptors from the list matching the search options. When opt.SortAnnotation is set, the order of descriptors with matching annotations is undefined.

func DescriptorListSearch

func DescriptorListSearch(dl []Descriptor, opt MatchOpt) (Descriptor, error)

DescriptorListSearch returns the first descriptor from the list matching the search options.

func (Descriptor) Equal

func (d Descriptor) Equal(d2 Descriptor) bool

Equal indicates the two descriptors are identical, effectively a DeepEqual.

func (Descriptor) GetData

func (d Descriptor) GetData() ([]byte, error)

GetData decodes the Data field from the descriptor if available

func (Descriptor) MarshalPrettyTW

func (d Descriptor) MarshalPrettyTW(tw *tabwriter.Writer, prefix string) error

func (Descriptor) Match

func (d Descriptor) Match(opt MatchOpt) bool

Match returns true if the descriptor matches the options, including compatible platforms.

func (Descriptor) Same

func (d Descriptor) Same(d2 Descriptor) bool

Same indicates two descriptors point to the same CAS object. This verifies the digest, media type, and size all match.

type MatchOpt

type MatchOpt struct {
	Platform       *platform.Platform // Platform to match including compatible platforms (darwin/arm64 matches linux/arm64)
	ArtifactType   string             // Match ArtifactType in the descriptor
	Annotations    map[string]string  // Match each of the specified annotations and their value, an empty value verifies the key is set
	SortAnnotation string             // Sort the results by an annotation, string based comparison, descriptors without the annotation are sorted last
	SortDesc       bool               // Set to true to sort in descending order
}

MatchOpt defines conditions for a match descriptor.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL