Documentation ¶
Index ¶
- Constants
- Variables
- func ApplyTextTemplate(temp string, config interface{}) (string, error)
- func ApplyTextTemplateErr(temp string, conf interface{}) ([]byte, error)
- func BuildTar(ents []TarEntry, opts ...BuildTarOption) io.Reader
- func BuildTarGz(ents []TarEntry, compressionLevel int, opts ...BuildTarOption) io.Reader
- func BuildTarZstd(ents []TarEntry, compressionLevel int, opts ...BuildTarOption) io.Reader
- func CopyInDir(sh *shell.Shell, from, to string) error
- func EnsureHello(ctx context.Context) (*ocispec.Descriptor, content.Store, error)
- func GetFilesAndContentsWithinTarGz(tarGz string) (map[string][]byte, []string, error)
- func GetProjectRoot() (string, error)
- func KillMatchingProcess(sh *shell.Shell, psLinePattern string) error
- func RandomByteData(size int64) []byte
- func RandomByteDataRange(minBytes int, maxBytes int) []byte
- func RandomDigest() string
- func RandomUInt64() (uint64, error)
- func StreamTestingLogToFile(destPath string) (func() error, error)
- func TempDir(sh *shell.Shell) (string, error)
- func TestingLogDest() (io.Writer, io.Writer)
- func WriteFileContents(sh *shell.Shell, name string, content []byte, mode uint32) error
- func WriteTarToTempFile(tarNamePattern string, tarReader io.Reader) (string, []byte, error)
- type BuildTarOption
- type BuildTarOptions
- type DirectoryBuildTarOption
- type FileBuildTarOption
- type RemoteSnapshotMonitor
- type RemoteSnapshotPreparedLogLine
- 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
- type TestingReporter
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" )
const (
BuildKitVersion = "v0.8.1"
)
Variables ¶
TestingL is a Logger instance used during testing. This allows tests to prints logs in realtime.
Functions ¶
func ApplyTextTemplate ¶
ApplyTextTemplate applies the config to the specified template.
func ApplyTextTemplateErr ¶
ApplyTextTemplateErr applies the config to the specified template.
func BuildTar ¶
func BuildTar(ents []TarEntry, opts ...BuildTarOption) io.Reader
BuildTar builds a tar given a list of tar entries and returns an io.Reader
func BuildTarGz ¶
func BuildTarGz(ents []TarEntry, compressionLevel int, opts ...BuildTarOption) io.Reader
BuildTarGz builds a tar.gz given a list of tar entries and returns an io.Reader
func BuildTarZstd ¶
func BuildTarZstd(ents []TarEntry, compressionLevel int, opts ...BuildTarOption) io.Reader
BuildTarZstd builds a tar blob with zstd compression.
func CopyInDir ¶
CopyInDir copies a directory into the specified location in the specified execution environment.
func EnsureHello ¶
EnsureHello creates a temp content store and ensures `hello-world` image from HelloArchiveURL into the store.
func GetFilesAndContentsWithinTarGz ¶
GetFilesAndContentsWithinTarGz takes a path to a targz archive and returns a list of its files and their contents
func GetProjectRoot ¶
GetProjectRoot returns the path to the directory where the source code of this project reside.
func KillMatchingProcess ¶
KillMatchingProcess kills processes that "ps" line matches the specified pattern in the specified execution environment.
func RandomByteData ¶
RandomByteData returns a byte slice with `size` populated with random generated data
func RandomByteDataRange ¶
RandomByteDataRange returns a byte slice with `size` between minBytes and maxBytes exclusive populated with random data
func RandomDigest ¶
func RandomDigest() string
RandomDigest generates a random digest from a random sequence of bytes
func RandomUInt64 ¶
RandomUInt64 returns a random uint64 value generated from /dev/uramdom.
func StreamTestingLogToFile ¶
StreamTestingLogToFile allows TestingL to stream the logging output to the speicified file.
func TestingLogDest ¶
TestingLogDest returns Writes of Testing.T.
func WriteFileContents ¶
WriteFileContents creates a file at the specified location in the specified execution environment and writes the specified contents to that file.
func WriteTarToTempFile ¶
WriteTarToTempFile writes the contents of a tar archive to a specified path and return the temp filename and the tar data (as []byte).
It's the caller's responsibility to remove the genreated temp file.
Types ¶
type BuildTarOption ¶
type BuildTarOption func(o *BuildTarOptions)
BuildTarOption is an option used during building blob.
func WithGzipComment ¶
func WithGzipComment(comment string) BuildTarOption
func WithGzipExtra ¶
func WithGzipExtra(extra []byte) BuildTarOption
func WithGzipFilename ¶
func WithGzipFilename(filename string) BuildTarOption
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 GzipComment string GzipFilename string GzipExtra []byte }
BuildTarOptions is a set of options used during building blob.
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 RemoteSnapshotMonitor ¶
type RemoteSnapshotMonitor struct {
// contains filtered or unexported fields
}
RemoteSnapshotMonitor scans log of soci snapshotter and provides the way to check if all snapshots are prepared as remote snpashots.
func NewRemoteSnapshotMonitor ¶
func NewRemoteSnapshotMonitor(r shell.Reporter, stdout, stderr io.Reader) *RemoteSnapshotMonitor
NewRemoteSnapshotMonitor creates a new instance of RemoteSnapshotMonitor that scans logs streamed from the specified io.Reader.
func (*RemoteSnapshotMonitor) CheckAllRemoteSnapshots ¶
func (m *RemoteSnapshotMonitor) CheckAllRemoteSnapshots(t *testing.T)
CheckAllRemoteSnapshots checks if the scanned log reports that all snapshots are prepared as remote snapshots.
func (*RemoteSnapshotMonitor) ScanLog ¶
func (m *RemoteSnapshotMonitor) ScanLog(inputR io.Reader)
ScanLog scans the log streamed from the specified io.Reader.
type RemoteSnapshotPreparedLogLine ¶
type RemoteSnapshotPreparedLogLine struct {
RemoteSnapshotPrepared string `json:"remote-snapshot-prepared"`
}
type TarEntry ¶
type TarEntry interface {
AppendTar(tw *tar.Writer, opts BuildTarOptions) error
}
TarEntry is an entry of tar.
func File ¶
func File(name, contents string, opts ...FileBuildTarOption) TarEntry
File is a regular file entry
type TestingReporter ¶
type TestingReporter struct {
// contains filtered or unexported fields
}
TestingReporter is an implementation of dockershell.Reporter backed by testing.T and TestingL.
func NewTestingReporter ¶
func NewTestingReporter(t *testing.T) *TestingReporter
NewTestingReporter returns a new TestingReporter instance for the specified testing.T.
func (*TestingReporter) Errorf ¶
func (r *TestingReporter) Errorf(format string, v ...interface{})
Errorf prints the provided message to TestingL and stops the test using testing.T.Fatalf.
func (*TestingReporter) Logf ¶
func (r *TestingReporter) Logf(format string, v ...interface{})
Logf prints the provided message to TestingL testing.T.
func (*TestingReporter) Stderr ¶
func (r *TestingReporter) Stderr() io.Writer
Stderr returns the writer to TestingL as stderr. This enables to print command logs realtime.
func (*TestingReporter) Stdout ¶
func (r *TestingReporter) Stdout() io.Writer
Stdout returns the writer to TestingL as stdout. This enables to print command logs realtime.