soci

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2024 License: Apache-2.0 Imports: 29 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"
	// IndexAnnotationDisableXAttrs is the index annotation if the layer has
	// extended attributes
	IndexAnnotationDisableXAttrs = "com.amazon.soci.disable-xattrs"
)

Variables

View Source
var (
	ErrArtifactBucketNotFound = errors.New("soci_artifacts not found")
)
View Source
var (
	ErrEmptyIndex = errors.New("no ztocs created, all layers either skipped or produced errors")
)

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 is 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)

MarshalIndex serializes a SOCI index into a JSON blob. The JSON blob is an OCI 1.0 Manifest

func UnmarshalIndex

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

UnmarshalIndex deserializes a JSON blob in a byte array into a SOCI index. The blob is an OCI 1.0 Manifest

func WriteSociIndex

func WriteSociIndex(ctx context.Context, indexWithMetadata *IndexWithMetadata, contentStore store.Store, 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 generate 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) GetArtifactEntriesByImageDigest added in v0.4.0

func (db *ArtifactsDb) GetArtifactEntriesByImageDigest(digest string) ([][]byte, error)

GetArtifactEntriesByImageDigest returns all index digests greated from a given image digest

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) RemoveArtifactEntryByIndexDigest

func (db *ArtifactsDb) RemoveArtifactEntryByIndexDigest(digest []byte) error

RemoveArtifactEntryByIndexDigest removes an index's artifact entry using its digest

func (*ArtifactsDb) RemoveOldArtifacts added in v0.4.0

func (db *ArtifactsDb) RemoveOldArtifacts(blobStore store.Store) error

RemoveOldArtifacts will remove any artifacts from the artifacts database that no longer exist in SOCIs local content store. NOTE: Removing buckets while iterating (bucket.ForEach) causes unexpected behavior (see: https://github.com/boltdb/bolt/issues/426). This implementation works around this issue by appending buckets to a slice when iterating and removing them after.

func (*ArtifactsDb) SyncWithLocalStore added in v0.3.0

func (db *ArtifactsDb) SyncWithLocalStore(ctx context.Context, blobStore store.Store, blobStorePath string, cs content.Store) error

SyncWithLocalStore will sync the artifacts databse with SOCIs local content store, either adding new or removing old artifacts.

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

WithArtifactsDb 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 WithNoDisableXAttrs added in v0.6.0

func WithNoDisableXAttrs() BuildOption

WithNoDisableXAttrs will skip checking DisableXAttrs annotation

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) *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 IndexWithMetadata

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

IndexWithMetadata has a soci `Index` and its metadata.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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