Documentation
¶
Overview ¶
Package encoding implements the protocol used to serialize and deserialize data across the wire.
Index ¶
- Constants
- func ExtraManifests(index *ocispec.Index) ([]ocispec.Descriptor, error)
- func IndexFallback(index *ocispec.Index)
- func IsImage(mt string) bool
- func IsIndex(mt string) bool
- func IsManifest(mt string) bool
- func IsOCICompliant(mt string) bool
- func Successors(ctx context.Context, fetcher content.Fetcher, desc ocispec.Descriptor) ([]ocispec.Descriptor, error)
- type EncodedWriteCloser
- type ManifestInfo
- type ManifestJSON
- type OCILayoutSerializer
- func (ow *OCILayoutSerializer) Close() error
- func (ow *OCILayoutSerializer) Flush() error
- func (ow *OCILayoutSerializer) SaveBlob(ctx context.Context, fetcher content.Fetcher, blob ocispec.Descriptor) error
- func (ow *OCILayoutSerializer) SaveIndex(index ocispec.Index) error
- func (ow *OCILayoutSerializer) SaveManifestJSON(mj ManifestJSON) error
- func (ow *OCILayoutSerializer) SaveOCILayout() error
- func (ow *OCILayoutSerializer) SkipBlob(desc ocispec.Descriptor)
- type TaggableTracker
- func (mt *TaggableTracker) AddBlob(ctx context.Context, h digest.Digest) error
- func (mt *TaggableTracker) KnownTaggable(h digest.Digest) (desc *ocispec.Descriptor)
- func (mt *TaggableTracker) MissingBlobs() []digest.Digest
- func (mt *TaggableTracker) NotifyManifest(ctx context.Context, desc ocispec.Descriptor) error
Constants ¶
const ( // AnnotationGatherVersion is the key for the annotation to denote the ace-dt version used during gather. AnnotationGatherVersion = "vnd.act3-ace.data.version" // AnnotationSerializationVersion is the key for the annotaion to denote the serialization format version. AnnotationSerializationVersion = "vnd.act3-ace.data.serialization.version" // AnnotationExtraManifests is the annotation key used for index of index descriptors. The value is a JSON encoded array of descriptors. AnnotationExtraManifests = "vnd.act3-ace.data.extra-manifests" // AnnotationLayerSizeTotal is the size (in bytes) of the layers. AnnotationLayerSizeTotal = "vnd.act3-ace.data.layer.size.total" // AnnotationLayerSizeDeduplicated is the size (in bytes) of the layers with duplicated removed. // This is the size that would need to be transferred if there was no data on the receiving side. AnnotationLayerSizeDeduplicated = "vnd.act3-ace.data.layer.size.deduplicated" // AnnotationArchiveOffset after this descriptor is written to the tar archive. This value is the number of bytes written to the tar archive. In other words it is the minimum number of bytes necessary (of the tar archive) needed to recover this descriptor. AnnotationArchiveOffset = "vnd.act3-ace.data.offset" // AnnotationLabels is the JSON encoded map of labels. AnnotationLabels = "data.act3-ace.io/labels" // AnnotationSrcIndex is the string source index of a manifest (sourced from a multi-architecture index). Its digest can be computed to get the original manifest digest/ID. AnnotationSrcIndex = "data.act3-ace.io/source-index" )
const ( MediaTypeDockerManifestList = "application/vnd.docker.distribution.manifest.list.v2+json" MediaTypeDockerManifest = "application/vnd.docker.distribution.manifest.v2+json" )
Docker compatible media types.
const (
// MediaTypeGather is the artifact type used for the gathered imaged.
MediaTypeGather = "application/vnd.act3-ace.data.gather+json"
)
Variables ¶
This section is empty.
Functions ¶
func ExtraManifests ¶
func ExtraManifests(index *ocispec.Index) ([]ocispec.Descriptor, error)
ExtraManifests extracts extra (shadow) manifests from the image index. This is to support registries not properly support index of index.
func IndexFallback ¶
IndexFallback HACK for JFrog and other registries that do not support Index of Index.
func IsManifest ¶
IsManifest returns true if this is any form of manifest/taggable (index or image).
func IsOCICompliant ¶
IsOCICompliant returns true if the manifest is of an official OCI media type (i.e., not docker).
func Successors ¶
func Successors(ctx context.Context, fetcher content.Fetcher, desc ocispec.Descriptor) ([]ocispec.Descriptor, error)
Successors implements the oras.CopyGraphOptions.FindSuccessors callback function. Successors finds the successors of the current node. fetcher provides cached access to the source storage, and is suitable for fetching non-leaf nodes like manifests. Since anything fetched from fetcher will be cached in the memory, it is recommended to use original source storage to fetch large blobs.
Types ¶
type EncodedWriteCloser ¶
EncodedWriteCloser allows writing to file in tar format while still being able to close the underlying zstd or gzip writer.
type ManifestInfo ¶
type ManifestInfo struct { Config string `json:"Config"` RepoTags []string `json:"RepoTags"` Layers []string `json:"Layers"` // contains filtered or unexported fields }
ManifestInfo is an entry in the manifest.json file.
type ManifestJSON ¶
type ManifestJSON struct { Manifests []ManifestInfo // contains filtered or unexported fields }
ManifestJSON is the top level structure of the manifest.json file.
func BuildManifestJSON ¶
func BuildManifestJSON(ctx context.Context, fetcher content.Fetcher, manifests []ocispec.Descriptor) (ManifestJSON, error)
BuildManifestJSON iterates through a list of manifests adding them to the manifest.json appropriately. If a manifest is an index, it selects one manifest from it prioritized by platform: user's current platform, linux/amd64, the first manifest in the index. If a user wants a specific platform they should use an image gathered with the appropriate platform option.
type OCILayoutSerializer ¶
type OCILayoutSerializer struct {
// contains filtered or unexported fields
}
OCILayoutSerializer handles writing of different types of data to the tar writer.
func NewOCILayoutSerializer ¶
func NewOCILayoutSerializer(dest io.Writer, compression string) (*OCILayoutSerializer, error)
NewOCILayoutSerializer creates a new serializer.
func NewOCILayoutSerializerWithLedger ¶
func NewOCILayoutSerializerWithLedger(dest, ledger io.Writer, compression string) (*OCILayoutSerializer, error)
NewOCILayoutSerializerWithLedger serialized data to dest and writes the ledger to ledger.
func (*OCILayoutSerializer) Close ¶
func (ow *OCILayoutSerializer) Close() error
Close will close the serializer.
func (*OCILayoutSerializer) Flush ¶
func (ow *OCILayoutSerializer) Flush() error
Flush finishes writing the current pending data.
func (*OCILayoutSerializer) SaveBlob ¶
func (ow *OCILayoutSerializer) SaveBlob(ctx context.Context, fetcher content.Fetcher, blob ocispec.Descriptor) error
SaveBlob writes a blob to the tar archive. This can be a layer, config, or manifest.
func (*OCILayoutSerializer) SaveIndex ¶
func (ow *OCILayoutSerializer) SaveIndex(index ocispec.Index) error
SaveIndex writes out the top level index.json file.
func (*OCILayoutSerializer) SaveManifestJSON ¶
func (ow *OCILayoutSerializer) SaveManifestJSON(mj ManifestJSON) error
SaveManifestJSON writes out the top level manifest.json file.
func (*OCILayoutSerializer) SaveOCILayout ¶
func (ow *OCILayoutSerializer) SaveOCILayout() error
SaveOCILayout write the OCI layout file to the tar stream.
func (*OCILayoutSerializer) SkipBlob ¶
func (ow *OCILayoutSerializer) SkipBlob(desc ocispec.Descriptor)
SkipBlob tells the serializer to never write a blob with the given digest.
type TaggableTracker ¶
type TaggableTracker struct { FindSuccessors func(ctx context.Context, fetcher content.Fetcher, desc ocispec.Descriptor) ([]ocispec.Descriptor, error) // contains filtered or unexported fields }
TaggableTracker is used to tack taggables as we become aware of them through the deserialize process.
func NewTaggableTracker ¶
func NewTaggableTracker(target content.Storage, cache content.Storage) *TaggableTracker
NewTaggableTracker creates a new tracker.
func (*TaggableTracker) AddBlob ¶
func (mt *TaggableTracker) AddBlob(ctx context.Context, h digest.Digest) error
AddBlob notifies the tracker that a blob was added to the registry. If it KnownTaggable(desc) != nil then the manifest data MUST be in the cache.
func (*TaggableTracker) KnownTaggable ¶
func (mt *TaggableTracker) KnownTaggable(h digest.Digest) (desc *ocispec.Descriptor)
KnownTaggable returns the descriptor if the digest refers to a taggable that is already known to the tracker. Nil otherwise. This is conservative so at a later time this might return a non-nil descriptor when it previously returned nil. As such, it can only be used for optimizations.
func (*TaggableTracker) MissingBlobs ¶
func (mt *TaggableTracker) MissingBlobs() []digest.Digest
MissingBlobs returns the digests of the blobs that are known to be missing given the manifests we know about. The missing digests do not contain duplicates and are sorted.
func (*TaggableTracker) NotifyManifest ¶
func (mt *TaggableTracker) NotifyManifest(ctx context.Context, desc ocispec.Descriptor) error
NotifyManifest notifies the tracker that the descriptor exists. That data need not exist yet.