util

package
Version: v0.0.0-...-58c381f Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2021 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package util provides utility methods for the agent.

Index

Constants

View Source
const (
	MarkerTaskID      = "EVR_TASK_ID"
	MarkerAgentPID    = "EVR_AGENT_PID"
	MarkerInEvergreen = "IN_EVERGREEN"
)

Variables

View Source
var ErrPSTimeout = errors.New("ps timeout")

Functions

func BuildArchive

func BuildArchive(ctx context.Context, tarWriter *tar.Writer, rootPath string, includes []string,
	excludes []string, logger grip.Journaler) (int, error)

BuildArchive reads the rootPath directory into the tar.Writer, taking included and excluded strings into account. Returns the number of files that were added to the archive

func ExitAgent

func ExitAgent()

func ExtractTarball

func ExtractTarball(ctx context.Context, reader io.Reader, rootPath string, excludes []string) error

func KillSpawnedProcs

func KillSpawnedProcs(ctx context.Context, key, workingDir string, logger grip.Journaler) error

KillSpawnedProcs kills processes that descend from the agent and waits for them to terminate.

func S3DefaultURL

func S3DefaultURL(bucket, key string) string

S3DefaultURL returns the S3 URL for the given bucket containing the object key. The style of the S3 URL is determined based on the bucket name.

func S3PathURL

func S3PathURL(bucket, key string) string

S3PathURL returns the path-style S3 URL for the given bucket containing the object key.

func S3VirtualHostedURL

func S3VirtualHostedURL(bucket, key string) string

S3VirtualHostedURL returns the virtual hosted-style S3 URL for the given bucket containing the object key.

func SpotHostWillTerminateSoon

func SpotHostWillTerminateSoon() bool

SpotHostWillTerminateSoon returns true if the EC2 spot host it is running on will terminate soon.

func TarGzReader

func TarGzReader(path string) (f, gz io.ReadCloser, tarReader *tar.Reader, err error)

TarGzReader returns a file, gzip reader, and tar reader for the given path. The tar reader wraps the gzip reader, which wraps the file.

func TarGzWriter

func TarGzWriter(path string) (f, gz io.WriteCloser, tarWriter *tar.Writer, err error)

TarGzWriter returns a file, gzip writer, and tarWriter for the path. The tar writer wraps the gzip writer, which wraps the file.

func TrackProcess

func TrackProcess(key string, pid int, logger grip.Journaler)

TrackProcess is a noop by default if we don't need to do any special bookkeeping up-front.

Types

type ArchiveContentFile

type ArchiveContentFile struct {
	Path string
	Info os.FileInfo
	// contains filtered or unexported fields
}

ArchiveContentFile represents a tar file on disk.

func FindContentsToArchive

func FindContentsToArchive(ctx context.Context, rootPath string, includes, excludes []string) ([]ArchiveContentFile, error)

FindContentsToArchive finds all files starting from the rootPath with the given inclusion and exclusion patterns.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL