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 GetContentStoreBlobPath(contentStoreType store.ContentStoreType) (string, error)
- func GetFilesAndContentsWithinTar(tarFile string) (map[string][]byte, []string, error)
- func GetFilesAndContentsWithinTarGz(tarGz string) (map[string][]byte, []string, error)
- func GetProjectRoot() (string, error)
- func InjectContentStoreContentFromBytes(sh *shell.Shell, contentStoreType store.ContentStoreType, ...) error
- func InjectContentStoreContentFromReader(sh *shell.Shell, contentStoreType store.ContentStoreType, ...) error
- func KillMatchingProcess(sh *shell.Shell, psLinePattern string) error
- func LogConfirmStartup(m *LogMonitor) error
- func RandomByteData(size int64) []byte
- func RandomByteDataRange(minBytes int, maxBytes int) []byte
- func RandomDigest() string
- func RandomUInt64() (uint64, error)
- func RemoveContentStoreContent(sh *shell.Shell, contentStoreType store.ContentStoreType, contentDigest string) 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 LevelLogLine
- type LogMonitor
- 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
- type ThreadsafeRandom
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"
)
const TestRandomSeed = 1658503010463818386
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 GetContentStoreBlobPath ¶ added in v0.4.0
func GetContentStoreBlobPath(contentStoreType store.ContentStoreType) (string, error)
GetContentStoreBlobPath returns the bottom level directory for the content store, e.g. "/blobs/sha256".
func GetFilesAndContentsWithinTar ¶ added in v0.3.0
GetFilesAndContentsWithinTar takes a path to a tar archive and returns a list of its files and their contents
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 InjectContentStoreContentFromBytes ¶ added in v0.4.0
func InjectContentStoreContentFromBytes(sh *shell.Shell, contentStoreType store.ContentStoreType, desc ocispec.Descriptor, content []byte) error
func InjectContentStoreContentFromReader ¶ added in v0.4.0
func InjectContentStoreContentFromReader(sh *shell.Shell, contentStoreType store.ContentStoreType, desc ocispec.Descriptor, content io.Reader) error
func KillMatchingProcess ¶
KillMatchingProcess kills processes that "ps" line matches the specified pattern in the specified execution environment.
func LogConfirmStartup ¶ added in v0.3.0
func LogConfirmStartup(m *LogMonitor) error
LogConfirmStartup registers a LogMonitor function to scan until startup succeeds or fails
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 RemoveContentStoreContent ¶ added in v0.4.0
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 LevelLogLine ¶ added in v0.3.0
type LogMonitor ¶ added in v0.3.0
type LogMonitor struct {
// contains filtered or unexported fields
}
LogMonitor manages a list of functions that should scan lines coming from stdout and stderr Readers
func NewLogMonitor ¶ added in v0.3.0
func NewLogMonitor(r shell.Reporter, stdout, stderr io.Reader) *LogMonitor
NewLogMonitor creates a LogMonitor for a given pair of stdout and stderr Readers
func (*LogMonitor) Add ¶ added in v0.3.0
func (m *LogMonitor) Add(name string, monitorFunc func(string)) error
Add registers a new log monitor function
func (*LogMonitor) Remove ¶ added in v0.3.0
func (m *LogMonitor) Remove(name string) error
Remove unregisters a log monitor function
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(m *LogMonitor) (*RemoteSnapshotMonitor, func())
NewRemoteSnapshotMonitor creates a new instance of RemoteSnapshotMonitor and registers it with the LogMonitor
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) MonitorFunc ¶ added in v0.3.0
func (m *RemoteSnapshotMonitor) MonitorFunc(rawL string)
MonitorFunc counts remote/local snapshot preparation totals
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.
type ThreadsafeRandom ¶ added in v0.4.0
type ThreadsafeRandom struct {
// contains filtered or unexported fields
}
ThreadsafeRandom is like rand.Rand with thread safety. rand.Rand is not threadsafe except for the global rand.Rand which is only accessible through the exported function on the rand package (e.g. rand.Int63()). This is done by special casing a non-exported rand.lockedSource which is locked before doing any modification of the source or rand. It's not possible to create our own lockedSource that implements `rand.Source` because `rand.Rand` itself is not threadsafe. The actual implementation gets around this by locking the `rand.Rand`'s source which effectively locks the `rand.Rand` as well. There is an expermiental version of rand that exports `rand.LockedSource`. If that ever lands, then we can remove all of this code and just use `r := rand.New(rand.NewLockedSource(seed))`. https://pkg.go.dev/golang.org/x/exp@v0.0.0-20230801115018-d63ba01acd4b/rand#LockedSource
func NewThreadsafeRandom ¶ added in v0.4.0
func NewThreadsafeRandom() *ThreadsafeRandom
func (*ThreadsafeRandom) Int63 ¶ added in v0.4.0
func (tsr *ThreadsafeRandom) Int63() int64
func (*ThreadsafeRandom) Intn ¶ added in v0.4.0
func (tsr *ThreadsafeRandom) Intn(n int) int