soci

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 15, 2023 License: Apache-2.0 Imports: 25 Imported by: 3

Documentation

Index

Constants

View Source
const (
	// SociIndexArtifactType is the artifactType of index SOCI index
	SociIndexArtifactType = "application/vnd.amazon.soci.index.v1+json"
	// SociLayerMediaType is the mediaType of ztoc
	SociLayerMediaType = "application/octet-stream"
	// IndexAnnotationImageLayerMediaType is the index annotation for image layer media type
	IndexAnnotationImageLayerMediaType = "com.amazon.soci.image-layer-mediaType"
	// IndexAnnotationImageLayerDigest is the index annotation for image layer digest
	IndexAnnotationImageLayerDigest = "com.amazon.soci.image-layer-digest"
	// IndexAnnotationBuildToolIdentifier is the index annotation for build tool identifier
	IndexAnnotationBuildToolIdentifier = "com.amazon.soci.build-tool-identifier"
)

Variables

This section is empty.

Functions

func ArtifactsDbPath

func ArtifactsDbPath() string

Get the default artifacts db path

func DecodeIndex

func DecodeIndex(r io.Reader, index *Index) error

DecodeIndex deserializes a JSON blob in an io.Reader into a SOCI index. The blob can be either an OCI 1.1 Artifact or an OCI 1.0 Manifest

func GetImageManifestDescriptor

func GetImageManifestDescriptor(ctx context.Context, cs content.Store, imageTarget ocispec.Descriptor, platform platforms.MatchComparer) (*ocispec.Descriptor, error)

GetImageManifestDescriptor gets the descriptor of image manifest

func MarshalIndex

func MarshalIndex(i *Index) ([]byte, error)

Marshal serializes a SOCI index into a JSON blob. The JSON blob will be either an OCI 1.1 Artifact or an OCI 1.0 Manifest, depending on how the index was created.

func UnmarshalIndex

func UnmarshalIndex(b []byte, index *Index) error

UnmarshalIndex deserializes a JSON blob in a byte array into a SOCI index. The blob can be either an OCI 1.1 Artifact or an OCI 1.0 Manifest

func WithIndexAsArtifact

func WithIndexAsArtifact(c *indexConfig) error

WithIndexAsArtifact sets whether to build SOCI index as an artifact manifest instead of an image manifest.

func WithOCIArtifactRegistrySupport

func WithOCIArtifactRegistrySupport(c *buildConfig) error

WithOCIArtifactRegistrySupport sets whether to build SOCI index as an artifact manifest instead of an image manifest. Artifact manifests are proposed within the OCI 1.1 spec and are only supported by OCI 1.1 compatible registries.

func WriteSociIndex

func WriteSociIndex(ctx context.Context, indexWithMetadata *IndexWithMetadata, store orascontent.Storage, artifactsDb *ArtifactsDb) error

WriteSociIndex writes the SociIndex manifest to oras `store`.

Types

type ArtifactEntry

type ArtifactEntry struct {
	// Size is the SOCI artifact's size in bytes.
	Size int64
	// Digest is the SOCI artifact's digest.
	Digest string
	// OriginalDigest is the digest of the content for which the SOCI artifact was created.
	OriginalDigest string
	// ImageDigest is the digest of the container image that was used to generat the artifact
	// ImageDigest refers to the image, OriginalDigest refers to the specific content within that
	// image that was used to generate the Artifact.
	ImageDigest string
	// Platform is the platform for which the artifact was generated.
	Platform string
	// Location is the file path for the SOCI artifact.
	Location string
	// Type is the type of SOCI artifact.
	Type ArtifactEntryType
	// Media Type of the stored artifact.
	MediaType string
	// Creation time of SOCI artifact.
	CreatedAt time.Time
}

ArtifactEntry is a metadata object for a SOCI artifact.

type ArtifactEntryType

type ArtifactEntryType string

ArtifactEntryType is the type of SOCI artifact represented by the ArtifactEntry

var (

	// ArtifactEntryTypeIndex indicates that an ArtifactEntry is a SOCI index artifact
	ArtifactEntryTypeIndex ArtifactEntryType = "soci_index"
	// ArtifactEntryTypeLayer indicates that an ArtifactEntry is a SOCI layer artifact
	ArtifactEntryTypeLayer ArtifactEntryType = "soci_layer"
)

type ArtifactsDb

type ArtifactsDb struct {
	// contains filtered or unexported fields
}

ArtifactsDB is a store for SOCI artifact metadata

func NewDB

func NewDB(path string) (*ArtifactsDb, error)

NewDB returns an instance of an ArtifactsDB

func (*ArtifactsDb) GetArtifactEntry

func (db *ArtifactsDb) GetArtifactEntry(digest string) (*ArtifactEntry, error)

GetArtifactEntry loads a single ArtifactEntry from the ArtifactsDB by digest

func (*ArtifactsDb) GetArtifactType

func (db *ArtifactsDb) GetArtifactType(digest string) (ArtifactEntryType, error)

GetArtifactType gets Type of an ArtifactEntry from the ArtifactsDB by digest

func (*ArtifactsDb) RemoveArtifactEntryByImageDigest

func (db *ArtifactsDb) RemoveArtifactEntryByImageDigest(digest string) error

RemoveArtifactEntryByIndexDigest removes an index's artifact entry using the image digest

func (*ArtifactsDb) RemoveArtifactEntryByIndexDigest

func (db *ArtifactsDb) RemoveArtifactEntryByIndexDigest(digest string) error

RemoveArtifactEntryByIndexDigest removes an index's artifact entry using its digest

func (*ArtifactsDb) Walk

func (db *ArtifactsDb) Walk(f func(*ArtifactEntry) error) error

Walk applys a function to all ArtifactEntries in the ArtifactsDB

func (*ArtifactsDb) WriteArtifactEntry

func (db *ArtifactsDb) WriteArtifactEntry(entry *ArtifactEntry) error

WriteArtifactEntry stores a single ArtifactEntry into the ArtifactsDB. If there is already an artifact in the ArtifactsDB with the same Digest, the old data is overwritten.

type BuildOption

type BuildOption func(c *buildConfig) error

BuildOption specifies a config change to build soci indices.

func WithArtifactsDb

func WithArtifactsDb(db *ArtifactsDb) BuildOption

Speicifies the artifacts database

func WithBuildToolIdentifier

func WithBuildToolIdentifier(tool string) BuildOption

WithBuildToolIdentifier specifies the build tool annotation value.

func WithMinLayerSize

func WithMinLayerSize(minLayerSize int64) BuildOption

WithMinLayerSize specifies min layer size to build a ztoc for a layer.

func WithPlatform

func WithPlatform(platform ocispec.Platform) BuildOption

WithPlatform specifies platform used to build soci indices.

func WithSpanSize

func WithSpanSize(spanSize int64) BuildOption

WithSpanSize specifies span size.

type Index

type Index struct {
	// MediaType represents the type of document into which the SOCI index manifest will be serialized
	MediaType string `json:"mediaType"`

	// Artifact type is the media type of the SOCI index itself.
	ArtifactType string `json:"artifactType"`

	// Blobs are descriptors for the zTOCs in the index.
	Blobs []ocispec.Descriptor `json:"blobs,omitempty"`

	// Subject is the descriptor for the resource to which the index applies.
	Subject *ocispec.Descriptor `json:"subject,omitempty"`

	// Annotations are optional additional metadata for the index.
	Annotations map[string]string `json:"annotations,omitempty"`
}

Index represents a SOCI index manifest.

func NewIndex

func NewIndex(blobs []ocispec.Descriptor, subject *ocispec.Descriptor, annotations map[string]string, opts ...IndexOption) *Index

NewIndex returns a new index.

func NewIndexFromReader

func NewIndexFromReader(reader io.Reader) (*Index, error)

NewIndexFromReader returns a new index from a Reader.

type IndexBuilder

type IndexBuilder struct {
	ArtifactsDb *ArtifactsDb
	// contains filtered or unexported fields
}

IndexBuilder creates soci indices.

func NewIndexBuilder

func NewIndexBuilder(contentStore content.Store, blobStore orascontent.Storage, artifactsDb *ArtifactsDb, opts ...BuildOption) (*IndexBuilder, error)

NewIndexBuilder returns an `IndexBuilder` that is used to create soci indices.

func (*IndexBuilder) Build

Build builds a soci index for `img` and return the index with metadata.

type IndexDescriptorInfo

type IndexDescriptorInfo struct {
	ocispec.Descriptor
	CreatedAt time.Time
}

IndexDescriptorInfo has a soci index descriptor and additional metadata.

func GetIndexDescriptorCollection

func GetIndexDescriptorCollection(ctx context.Context, cs content.Store, artifactsDb *ArtifactsDb, img images.Image, ps []ocispec.Platform) ([]IndexDescriptorInfo, *ocispec.Descriptor, error)

GetIndexDescriptorCollection returns all `IndexDescriptorInfo` of the given image and platforms.

type IndexOption

type IndexOption func(c *indexConfig) error

IndexOption specifies a config change for index creation.

type IndexWithMetadata

type IndexWithMetadata struct {
	Index       *Index
	Platform    *ocispec.Platform
	ImageDigest digest.Digest
	CreatedAt   time.Time
}

IndexWithMetadata has a soci `Index` and its metadata.

Jump to

Keyboard shortcuts

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