version_checker

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package version_checker provides utilities for checking binary versions against constraints.

Deprecated: The version_checker package is scheduled for removal in Terratest v2. It offers marginal value over shelling out to verify a binary's version yourself; do that instead. There is no public replacement; the package is being dropped.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckVersion deprecated

func CheckVersion(
	t testing.TestingT,
	params CheckVersionParams)

CheckVersion checks whether the given Binary version is greater than or equal to the given expected version and fails if it's not.

Deprecated: scheduled for removal in Terratest v2. Verify the version yourself, e.g. run "<binary> --version", extract with a regexp, and compare with go-version:

out, _ := exec.Command(binaryPath, "--version").Output()
v := regexp.MustCompile(`\d+(\.\d+)+`).FindString(string(out))
c, _ := version.NewConstraint(">= 1.2.0, < 2.0.0")
ok := c.Check(version.Must(version.NewVersion(v)))

func CheckVersionConstraint deprecated added in v1.0.0

func CheckVersionConstraint(actualVersionStr string, versionConstraintStr string) error

CheckVersionConstraint checks whether the given version passes the version constraint.

It returns InvalidVersionFormatErr for ill-formatted version strings and VersionMismatchErr when the version does not satisfy the constraint.

CheckVersionConstraint("1.2.31",  ">= 1.2.0, < 2.0.0") - no error
CheckVersionConstraint("1.0.31",  ">= 1.2.0, < 2.0.0") - error

Deprecated: scheduled for removal in Terratest v2 along with the version_checker package. Compare with github.com/hashicorp/go-version directly, e.g.

c, _ := version.NewConstraint(versionConstraintStr)
ok := c.Check(version.Must(version.NewVersion(actualVersionStr)))

func CheckVersionContext deprecated added in v1.0.0

func CheckVersionContext(
	t testing.TestingT,
	ctx context.Context,
	params CheckVersionParams)

CheckVersionContext is like CheckVersion but includes a context.

Deprecated: scheduled for removal in Terratest v2. Verify the version yourself, e.g. run "<binary> --version", extract with a regexp, and compare with go-version:

out, _ := exec.Command(binaryPath, "--version").Output()
v := regexp.MustCompile(`\d+(\.\d+)+`).FindString(string(out))
c, _ := version.NewConstraint(">= 1.2.0, < 2.0.0")
ok := c.Check(version.Must(version.NewVersion(v)))

func CheckVersionContextE deprecated added in v1.0.0

func CheckVersionContextE(
	t testing.TestingT,
	ctx context.Context,
	params CheckVersionParams) error

CheckVersionContextE is like CheckVersionE but includes a context.

Deprecated: scheduled for removal in Terratest v2. Verify the version yourself, e.g. run "<binary> --version", extract with a regexp, and compare with go-version:

out, _ := exec.Command(binaryPath, "--version").Output()
v := regexp.MustCompile(`\d+(\.\d+)+`).FindString(string(out))
c, _ := version.NewConstraint(">= 1.2.0, < 2.0.0")
ok := c.Check(version.Must(version.NewVersion(v)))

func CheckVersionE deprecated

func CheckVersionE(
	t testing.TestingT,
	params CheckVersionParams) error

CheckVersionE checks whether the given Binary version is greater than or equal to the given expected version.

Deprecated: scheduled for removal in Terratest v2. Verify the version yourself, e.g. run "<binary> --version", extract with a regexp, and compare with go-version:

out, _ := exec.Command(binaryPath, "--version").Output()
v := regexp.MustCompile(`\d+(\.\d+)+`).FindString(string(out))
c, _ := version.NewConstraint(">= 1.2.0, < 2.0.0")
ok := c.Check(version.Must(version.NewVersion(v)))

func ExtractVersionFromShellCommandOutput deprecated added in v1.0.0

func ExtractVersionFromShellCommandOutput(output string) (string, error)

ExtractVersionFromShellCommandOutput extracts version with regex string matching from the given shell command output string.

Deprecated: scheduled for removal in Terratest v2 along with the version_checker package. Extract the version yourself, e.g. regexp.MustCompile(`\d+(\.\d+)+`).FindString(output).

Types

type CheckVersionParams deprecated

type CheckVersionParams struct {
	// BinaryPath is a path to the binary you want to check the version for.
	BinaryPath string
	// VersionConstraint is a string literal containing one or more conditions, which are separated by commas.
	// More information here:https://www.terraform.io/language/expressions/version-constraints
	VersionConstraint string
	// WorkingDir is a directory you want to run the shell command.
	WorkingDir string
	// Binary is the name of the binary you want to check the version for.
	Binary VersionCheckerBinary
}

CheckVersionParams contains the parameters for checking a binary's version.

Deprecated: scheduled for removal in Terratest v2 along with the version_checker package.

type InvalidVersionConstraintErr deprecated added in v1.0.0

type InvalidVersionConstraintErr struct {
	Underlying error
	Constraint string
}

InvalidVersionConstraintErr is returned when the VersionConstraint string cannot be parsed.

Deprecated: scheduled for removal in Terratest v2 along with the version_checker package.

func (*InvalidVersionConstraintErr) Error added in v1.0.0

func (*InvalidVersionConstraintErr) Unwrap added in v1.0.0

func (e *InvalidVersionConstraintErr) Unwrap() error

type InvalidVersionFormatErr deprecated added in v1.0.0

type InvalidVersionFormatErr struct {
	Underlying error
	Field      string
	Value      string
}

InvalidVersionFormatErr is returned when a version string cannot be parsed.

Deprecated: scheduled for removal in Terratest v2 along with the version_checker package.

func (*InvalidVersionFormatErr) Error added in v1.0.0

func (e *InvalidVersionFormatErr) Error() string

func (*InvalidVersionFormatErr) Unwrap added in v1.0.0

func (e *InvalidVersionFormatErr) Unwrap() error

type MissingParamErr deprecated added in v1.0.0

type MissingParamErr struct {
	Param string
}

MissingParamErr is returned when a required field in CheckVersionParams is empty.

Deprecated: scheduled for removal in Terratest v2 along with the version_checker package.

func (*MissingParamErr) Error added in v1.0.0

func (e *MissingParamErr) Error() string

type UnsupportedBinaryErr deprecated added in v1.0.0

type UnsupportedBinaryErr struct {
	Binary VersionCheckerBinary
}

UnsupportedBinaryErr is returned when CheckVersionParams.Binary is set to an unknown VersionCheckerBinary value.

Deprecated: scheduled for removal in Terratest v2 along with the version_checker package.

func (*UnsupportedBinaryErr) Error added in v1.0.0

func (e *UnsupportedBinaryErr) Error() string

type VersionCheckerBinary deprecated

type VersionCheckerBinary int

VersionCheckerBinary is an enum for supported version checking.

Deprecated: scheduled for removal in Terratest v2 along with the version_checker package.

const (
	Docker VersionCheckerBinary = iota
	Terraform
	Packer
)

List of binaries supported for version checking.

Deprecated: scheduled for removal in Terratest v2 along with the version_checker package.

type VersionExtractionErr deprecated added in v1.0.0

type VersionExtractionErr struct {
	Output string
}

VersionExtractionErr is returned when the version string cannot be parsed from the output of running a binary's --version command.

Deprecated: scheduled for removal in Terratest v2 along with the version_checker package.

func (*VersionExtractionErr) Error added in v1.0.0

func (e *VersionExtractionErr) Error() string

type VersionMismatchErr deprecated

type VersionMismatchErr struct {
	Actual     string
	Constraint string
}

VersionMismatchErr is returned when a binary's version does not satisfy the given version constraint.

Deprecated: scheduled for removal in Terratest v2 along with the version_checker package.

func (*VersionMismatchErr) Error

func (e *VersionMismatchErr) Error() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL