package testutil
import "github.com/containerd/stargz-snapshotter/util/testutil"
Index ¶
- Constants
- func BuildEStargz(ents []TarEntry, opts ...BuildEStargzOption) (*io.SectionReader, digest.Digest, error)
- func BuildTar(ents []TarEntry, opts ...BuildTarOption) io.Reader
- func EnsureHello(ctx context.Context) (*ocispec.Descriptor, content.Store, error)
- func RandomBytes(t *testing.T, n int) []byte
- type BuildEStargzOption
- func WithBuildTarOptions(to ...BuildTarOption) BuildEStargzOption
- func WithEStargzOptions(eo ...estargz.Option) BuildEStargzOption
- type BuildTarOption
- type BuildTarOptions
- type Compression
- type CompressionFactory
- func ExternalTOCGzipCompressionWithLevel(compressionLevel int) CompressionFactory
- func GzipCompressionWithLevel(compressionLevel int) CompressionFactory
- func ZstdCompressionWithLevel(compressionLevel zstd.EncoderLevel) CompressionFactory
- type DirectoryBuildTarOption
- func WithDirModTime(modTime time.Time) DirectoryBuildTarOption
- func WithDirMode(mode os.FileMode) DirectoryBuildTarOption
- func WithDirOwner(uid, gid int) DirectoryBuildTarOption
- func WithDirXattrs(xattrs map[string]string) DirectoryBuildTarOption
- type FileBuildTarOption
- func WithFileModTime(modTime time.Time) FileBuildTarOption
- func WithFileMode(mode os.FileMode) FileBuildTarOption
- func WithFileOwner(uid, gid int) FileBuildTarOption
- func WithFileXattrs(xattrs map[string]string) FileBuildTarOption
- type TarEntry
- func Blockdev(name string, major, minor int64) TarEntry
- func Chardev(name string, major, minor int64) TarEntry
- func Dir(name string, opts ...DirectoryBuildTarOption) TarEntry
- func Fifo(name string) TarEntry
- func File(name, contents string, opts ...FileBuildTarOption) TarEntry
- func Link(name, linkname string) TarEntry
- func Symlink(name, target string) TarEntry
Constants ¶
const ( // HelloArchiveURL points to an OCI archive of `hello-world`. // Exported from `docker.io/library/hello-world@sha256:1a523af650137b8accdaed439c17d684df61ee4d74feac151b5b337bd29e7eec` . // See https://github.com/AkihiroSuda/test-oci-archives/releases/tag/v20210101 HelloArchiveURL = "https://github.com/AkihiroSuda/test-oci-archives/releases/download/v20210101/hello-world.tar.gz" // HelloArchiveDigest is the digest of the archive. HelloArchiveDigest = "sha256:5aa022621c4de0e941ab2a30d4569c403e156b4ba2de2ec32e382ae8679f40e1" )
Functions ¶
func BuildEStargz ¶
func BuildEStargz(ents []TarEntry, opts ...BuildEStargzOption) (*io.SectionReader, digest.Digest, error)
func BuildTar ¶
func BuildTar(ents []TarEntry, opts ...BuildTarOption) io.Reader
BuildTar builds a tar blob
func EnsureHello ¶
EnsureHello creates a temp content store and ensures `hello-world` image from HelloArchiveURL into the store.
func RandomBytes ¶
RandomBytes returns the specified number of random bytes
Types ¶
type BuildEStargzOption ¶
type BuildEStargzOption func(o *buildEStargzOptions) error
func WithBuildTarOptions ¶
func WithBuildTarOptions(to ...BuildTarOption) BuildEStargzOption
WithBuildTarOptions option specifies the options for tar creation
func WithEStargzOptions ¶
func WithEStargzOptions(eo ...estargz.Option) BuildEStargzOption
WithEStargzOptions specifies options for estargz lib
type BuildTarOption ¶
type BuildTarOption func(o *BuildTarOptions)
BuildTarOption is an option used during building blob.
func WithPrefix ¶
func WithPrefix(prefix string) BuildTarOption
WithPrefix is an option to add a prefix string to each file name (e.g. "./", "/", etc.)
type BuildTarOptions ¶
type BuildTarOptions struct { // Prefix is the prefix string need to be added to each file name (e.g. "./", "/", etc.) Prefix string }
BuildTarOptions is a set of options used during building blob.
type Compression ¶
type Compression interface { estargz.Compressor estargz.Decompressor // DecompressTOC decompresses the passed blob and returns a reader of TOC JSON. // This is needed to be used from metadata pkg DecompressTOC(io.Reader) (tocJSON io.ReadCloser, err error) }
type CompressionFactory ¶
type CompressionFactory func() Compression
func ExternalTOCGzipCompressionWithLevel ¶
func ExternalTOCGzipCompressionWithLevel(compressionLevel int) CompressionFactory
func GzipCompressionWithLevel ¶
func GzipCompressionWithLevel(compressionLevel int) CompressionFactory
func ZstdCompressionWithLevel ¶
func ZstdCompressionWithLevel(compressionLevel zstd.EncoderLevel) CompressionFactory
type DirectoryBuildTarOption ¶
type DirectoryBuildTarOption func(o *dirOpts)
DirectoryBuildTarOption is an option for a directory entry.
func WithDirModTime ¶
func WithDirModTime(modTime time.Time) DirectoryBuildTarOption
WithDirModTime specifies the modtime of the dir.
func WithDirMode ¶
func WithDirMode(mode os.FileMode) DirectoryBuildTarOption
WithDirMode specifies the mode of the directory.
func WithDirOwner ¶
func WithDirOwner(uid, gid int) DirectoryBuildTarOption
WithDirOwner specifies the owner of the directory.
func WithDirXattrs ¶
func WithDirXattrs(xattrs map[string]string) DirectoryBuildTarOption
WithDirXattrs specifies the extended attributes of the directory.
type FileBuildTarOption ¶
type FileBuildTarOption func(o *fileOpts)
FileBuildTarOption is an option for a file entry.
func WithFileModTime ¶
func WithFileModTime(modTime time.Time) FileBuildTarOption
WithFileModTime specifies the modtime of the file.
func WithFileMode ¶
func WithFileMode(mode os.FileMode) FileBuildTarOption
WithFileMode specifies the mode of the file.
func WithFileOwner ¶
func WithFileOwner(uid, gid int) FileBuildTarOption
WithFileOwner specifies the owner of the file.
func WithFileXattrs ¶
func WithFileXattrs(xattrs map[string]string) FileBuildTarOption
WithFileXattrs specifies the extended attributes of the file.
type TarEntry ¶
type TarEntry interface { AppendTar(tw *tar.Writer, opts BuildTarOptions) error }
TarEntry is an entry of tar.
func Blockdev ¶
Blockdev is a block device entry
func Chardev ¶
Chardev is a character device entry
func Dir ¶
func Dir(name string, opts ...DirectoryBuildTarOption) TarEntry
Dir is a directory entry
func Fifo ¶
Fifo is a fifo entry
func File ¶
func File(name, contents string, opts ...FileBuildTarOption) TarEntry
File is a regilar file entry
func Link ¶
Link is a hard-link entry
func Symlink ¶
Symlink is a symlink entry
Source Files ¶
compression.go ensurehello.go estargz.go tar.go util.go
- Version
- v0.16.3 (latest)
- Published
- Dec 12, 2024
- Platform
- linux/amd64
- Imports
- 21 packages
- Last checked
- 2 weeks ago –
Tools for package owners.