Documentation ¶
Index ¶
- func SizeOfContent(t Content) int64
- func SizeOfManifest(t Content) int64
- type Content
- type ContentCreator
- type ContentSizeCalculator
- type ContentStore
- func (tc ContentStore) Blob(mediaType string, data []byte) Content
- func (tc ContentStore) Index(manifests ...Content) Content
- func (tc ContentStore) JSONObject(mediaType string, i interface{}) Content
- func (tc ContentStore) Manifest(config Content, layers ...Content) Content
- func (tc ContentStore) RandomBlob(mediaType string, n int) Content
- func (tc ContentStore) Walk(c Content, fn func(context.Context, *Content, content.Store) error) Content
- type Size
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SizeOfContent ¶
SizeOfContent recursively calculates the size of all stored content The calculation is a simple accumulation based on the structure, duplicate blobs are not accounted for.
func SizeOfManifest ¶
SizeOfManifest recursively calculates the manifest reported size, not accounting for duplicate entries.
Types ¶
type Content ¶
type Content struct { Descriptor ocispec.Descriptor Labels map[string]string Size Size Children []Content }
Content represents a piece of image content in the content store along with its relevant children and size.
func AddPlatform ¶
AddPlatform alters the content desciptor by setting the platform
func LimitChildren ¶
LimitChildren limits the amount of children in the content. This function is non-recursive and uses the natural ordering.
type ContentCreator ¶
type ContentCreator func(ContentStore) Content
ContentCreator is a simple interface for generating content for tests
func SimpleIndex ¶
func SimpleIndex(manifests, layerSize int) ContentCreator
SimpleIndex generates a simple index with the number of simple manifests specified.
func SimpleManifest ¶
func SimpleManifest(layerSize int) ContentCreator
SimpleManifest generates a simple manifest with small config and random layer The layer produced is not a valid compressed tar, do not unpack it.
func StripLayers ¶
func StripLayers(cc ContentCreator) ContentCreator
StripLayers deletes all layer content from the content store and updates the content size to 0.
type ContentSizeCalculator ¶
ContentSizeCalculator calculates a size property for the test content
type ContentStore ¶
ContentStore is a temporary content store which provides simple helper functions for quickly altering content in the store. Directly modifying the content store without using the helper functions may result in out of sync test content values, be careful of this when writing tests.
func NewContentStore ¶
func NewContentStore(ctx context.Context, t *testing.T) ContentStore
NewContentStore creates a new content store in the testing's temporary directory
func (ContentStore) Blob ¶
func (tc ContentStore) Blob(mediaType string, data []byte) Content
Blob creates a generic blob with the given data and media type and stores the data in the content store.
func (ContentStore) Index ¶
func (tc ContentStore) Index(manifests ...Content) Content
Index creates an index with the provided manifests and stores it in the content store.
func (ContentStore) JSONObject ¶
func (tc ContentStore) JSONObject(mediaType string, i interface{}) Content
JSONObject creates an object in the content store by first marshaling to JSON and then storing the data.
func (ContentStore) Manifest ¶
func (tc ContentStore) Manifest(config Content, layers ...Content) Content
Manifest creates a manifest with the given config and layers then stores it in the content store.
func (ContentStore) RandomBlob ¶
func (tc ContentStore) RandomBlob(mediaType string, n int) Content
RandomBlob creates a blob object in the content store with random data.
func (ContentStore) Walk ¶
func (tc ContentStore) Walk(c Content, fn func(context.Context, *Content, content.Store) error) Content
Walk walks all the children of the provided content and calls the provided function with the associated content store. Walk can be used to update an object and reflect that change in the content store.
type Size ¶
type Size struct { // Manifest is the total Manifest reported size of current object and children Manifest int64 // Content is the total of store Content of current object and children Content int64 // Unpacked is the total size of Unpacked data for the given snapshotter // The key is the snapshotter name // The value is the usage reported by the snapshotter for the image Unpacked map[string]int64 // Uncompressed is the total Uncompressed tar stream data (used for size estimate) Uncompressed int64 }
Size represents the size of an object from different methods of counting, in bytes