imagetest

package
v2.0.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SizeOfContent

func SizeOfContent(t Content) int64

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

func SizeOfManifest(t Content) int64

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

func AddPlatform(c Content, p ocispec.Platform) Content

AddPlatform alters the content desciptor by setting the platform

func LimitChildren

func LimitChildren(c Content, limit int) Content

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

type ContentSizeCalculator func(Content) int64

ContentSizeCalculator calculates a size property for the test content

type ContentStore

type ContentStore struct {
	content.Store
	// contains filtered or unexported fields
}

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

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

Jump to

Keyboard shortcuts

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