Documentation ¶
Index ¶
- func CheckRecover(cause interface{}, cb func(int, error)) bool
- func Exit(code int, msg string, args ...interface{})
- func ExitCause(code int, err error, msg string, args ...interface{})
- func HandleExitWithCode()
- type Env
- func (e *Env) CheckCoherence()
- func (e *Env) EnsureBaseDirs(ctx context.Context)
- func (e *Env) EnsureVersionIsSet(ctx context.Context)
- func (e *Env) ExistsAndValid() bool
- func (e *Env) Fetch(ctx context.Context)
- func (e *Env) LatestVersion(ctx context.Context) (versions.Concrete, versions.PlatformItem)
- func (e *Env) ListVersions(ctx context.Context)
- func (e *Env) PathMatches(value string) bool
- func (e *Env) PrintInfo(printFmt PrintFormat)
- func (e *Env) Remove(ctx context.Context)
- func (e *Env) Sideload(ctx context.Context, input io.Reader)
- type PrintFormat
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckRecover ¶
CheckRecover checks the value of cause, calling the given callback if it's an exitCode error. It returns true if we should re-panic the cause.
It's mainly useful for testing, normally you'd use HandleExitWithCode.
func Exit ¶
Exit exits with the given code and error message.
Defer HandleExitWithCode in main to catch this and get the right behavior.
func ExitCause ¶
ExitCause exits with the given code and error message, automatically wrapping the underlying error passed as well.
Defer HandleExitWithCode in main to catch this and get the right behavior.
func HandleExitWithCode ¶
func HandleExitWithCode()
HandleExitWithCode handles panics of type exitCode, printing the status message and existing with the given exit code, or re-raising if not an exitCode error.
This should be the first defer in your main function.
Types ¶
type Env ¶
type Env struct { // Platform is our current platform Platform versions.PlatformItem // VerifiySum indicates whether or not we should run checksums. VerifySum bool // NoDownload forces us to not contact GCS, looking only // at local files instead. NoDownload bool // ForceDownload forces us to ignore local files and always // contact GCS & re-download. ForceDownload bool // Client is our remote client for contacting GCS. Client *remote.Client // Log allows us to log. Log logr.Logger // Version is the version(s) that we want to download // (may be automatically retrieved later on). Version versions.Spec // Store is used to load/store entries to/from disk. Store *store.Store // FS is the file system to read from/write to for provisioning temp files // for storing the archives temporarily. FS afero.Afero // Out is the place to write output text to Out io.Writer // contains filtered or unexported fields }
Env represents an environment for downloading and otherwise manipulating envtest binaries.
In general, the methods will use the Exit{,Cause} functions from this package to indicate errors. Catch them with a `defer HandleExitWithCode()`.
func (*Env) CheckCoherence ¶
func (e *Env) CheckCoherence()
CheckCoherence checks that this environment has filled-out, coherent settings (e.g. NoDownload & ForceDownload aren't both set).
func (*Env) EnsureBaseDirs ¶
EnsureBaseDirs ensures that the base packed and unpacked directories exist.
This should be the first thing called after CheckCoherence.
func (*Env) EnsureVersionIsSet ¶
EnsureVersionIsSet ensures that we have a non-wildcard version configured.
If necessary, it will enumerate on-disk and remote versions to accomplish this, finding a version that matches our version selector and platform. It will always yield a concrete version, it *may* yield a concrete platorm as well.
func (*Env) ExistsAndValid ¶
ExistsAndValid checks if our current (concrete) version & platform exist on disk (unless ForceDownload is set, in which cause it always returns false).
Must be called after EnsureVersionIsSet so that we have a concrete Version selected. Must have a concrete platform, or ForceDownload must be set.
func (*Env) Fetch ¶
Fetch ensures that the requested platform and version are on disk. You must call EnsureVersionIsSet before calling this method.
If ForceDownload is set, we always download, otherwise we only download if we're missing the version on disk.
func (*Env) LatestVersion ¶
LatestVersion returns the latest version matching our version selector and platform from the remote server, with the correspoding checksum for later use as well.
func (*Env) ListVersions ¶
ListVersions prints out all available versions matching this Env's platform & version selector (respecting NoDownload to figure out whether or not to match remote versions).
func (*Env) PathMatches ¶
PathMatches checks if the path (e.g. from the environment variable) matches this version & platform selector, and if so, returns true.
func (*Env) PrintInfo ¶
func (e *Env) PrintInfo(printFmt PrintFormat)
PrintInfo prints out information about a single, current version and platform, according to the given formatting info.
type PrintFormat ¶
type PrintFormat int
PrintFormat indicates how to print out fetch and switch results. It's a valid pflag.Value so it can be used as a flag directly.
const ( // PrintOverview prints human-readable data, // including path, version, arch, and checksum (when available). PrintOverview PrintFormat = iota // PrintPath prints *only* the path, with no decoration. PrintPath // PrintEnv prints the path with the corresponding env variable, so that // you can source the output like // `source $(fetch-envtest switch -p env 1.20.x)`. PrintEnv )
func (*PrintFormat) Set ¶
func (f *PrintFormat) Set(val string) error
Set sets the value of this as a flag.
func (PrintFormat) String ¶
func (f PrintFormat) String() string
func (PrintFormat) Type ¶
func (PrintFormat) Type() string
Type is the type of this value as a flag.