Documentation ¶
Index ¶
- Constants
- Variables
- func ArtifactsDbPath() string
- func DecodeIndex(r io.Reader, index *Index) error
- func GetImageManifestDescriptor(ctx context.Context, cs content.Store, imageTarget ocispec.Descriptor, ...) (*ocispec.Descriptor, error)
- func MarshalIndex(i *Index) ([]byte, error)
- func UnmarshalIndex(b []byte, index *Index) error
- type ArtifactEntry
- type ArtifactEntryType
- type ArtifactsDb
- func (db *ArtifactsDb) GetArtifactEntriesByImageDigest(digest string) ([][]byte, error)
- func (db *ArtifactsDb) GetArtifactEntry(digest string) (*ArtifactEntry, error)
- func (db *ArtifactsDb) GetArtifactType(digest string) (ArtifactEntryType, error)
- func (db *ArtifactsDb) RemoveArtifactEntryByIndexDigest(digest []byte) error
- func (db *ArtifactsDb) RemoveOldArtifacts(blobStore store.Store) error
- func (db *ArtifactsDb) SyncWithLocalStore(ctx context.Context, blobStore store.Store, blobStorePath string, ...) error
- func (db *ArtifactsDb) Walk(f func(*ArtifactEntry) error) error
- func (db *ArtifactsDb) WriteArtifactEntry(entry *ArtifactEntry) error
- type BuildOption
- func WithArtifactsDb(db *ArtifactsDb) BuildOption
- func WithBuildToolIdentifier(tool string) BuildOption
- func WithMinLayerSize(minLayerSize int64) BuildOption
- func WithOptimizations(optimizations []Optimization) BuildOption
- func WithPlatform(platform ocispec.Platform) BuildOption
- func WithSpanSize(spanSize int64) BuildOption
- type Index
- type IndexBuilder
- type IndexDescriptorInfo
- type IndexWithMetadata
- type Optimization
Constants ¶
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 ¶
var (
ErrArtifactBucketNotFound = errors.New("soci_artifacts not found")
)
var (
ErrEmptyIndex = errors.New("no ztocs created, all layers either skipped or produced errors")
)
var Optimizations = []Optimization{XAttrOptimization}
Optimizations contains the list of all known optimizations
Functions ¶
func DecodeIndex ¶
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 ¶
MarshalIndex serializes a SOCI index into a JSON blob. The JSON blob is an OCI 1.0 Manifest
func UnmarshalIndex ¶
UnmarshalIndex deserializes a JSON blob in a byte array into a SOCI index. The blob is an OCI 1.0 Manifest
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 WithOptimizations ¶ added in v0.7.0
func WithOptimizations(optimizations []Optimization) BuildOption
WithOptimizations enables optional optimizations when building the SOCI Index (experimental)
func WithPlatform ¶
func WithPlatform(platform ocispec.Platform) BuildOption
WithPlatform specifies platform used to build soci indices.
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.
type IndexBuilder ¶
type IndexBuilder struct { ArtifactsDb *ArtifactsDb // contains filtered or unexported fields }
IndexBuilder creates soci indices.
func NewIndexBuilder ¶
func NewIndexBuilder(contentStore content.Store, blobStore store.Store, artifactsDb *ArtifactsDb, opts ...BuildOption) (*IndexBuilder, error)
NewIndexBuilder returns an `IndexBuilder` that is used to create soci indices.
func (*IndexBuilder) Build ¶
func (b *IndexBuilder) Build(ctx context.Context, img images.Image) (*IndexWithMetadata, error)
Build builds a soci index for `img` and pushes it with its corresponding zTOCs to the blob store. Returns the SOCI index and its 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.
type Optimization ¶ added in v0.7.0
type Optimization string
Optimization represents an optional optimization to be applied when building the SOCI index
const ( // XAttrOptimization optimizes xattrs by disabling them for layers where there are no xattrs or opaque directories XAttrOptimization Optimization = "xattr" )
func ParseOptimization ¶ added in v0.7.0
func ParseOptimization(s string) (Optimization, error)
ParseOptimization parses a string into a known optimization. If the string does not match a known optimization, an error is returned.