Documentation
¶
Overview ¶
Package version_checker provides utilities for checking binary versions against constraints.
Index ¶
- func CheckVersion(t testing.TestingT, params CheckVersionParams)deprecated
- func CheckVersionConstraint(actualVersionStr string, versionConstraintStr string) error
- func CheckVersionContext(t testing.TestingT, ctx context.Context, params CheckVersionParams)
- func CheckVersionContextE(t testing.TestingT, ctx context.Context, params CheckVersionParams) error
- func CheckVersionE(t testing.TestingT, params CheckVersionParams) errordeprecated
- func ExtractVersionFromShellCommandOutput(output string) (string, error)
- type CheckVersionParams
- type InvalidVersionConstraintErr
- type InvalidVersionFormatErr
- type MissingParamErr
- type UnsupportedBinaryErr
- type VersionCheckerBinary
- type VersionExtractionErr
- type VersionMismatchErr
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: Use CheckVersionContext instead.
func CheckVersionConstraint ¶ added in v1.0.0
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
func CheckVersionContext ¶ added in v1.0.0
func CheckVersionContext( t testing.TestingT, ctx context.Context, params CheckVersionParams)
CheckVersionContext is like CheckVersion but includes a context.
func CheckVersionContextE ¶ added in v1.0.0
func CheckVersionContextE( t testing.TestingT, ctx context.Context, params CheckVersionParams) error
CheckVersionContextE is like CheckVersionE but includes a context.
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: Use CheckVersionContextE instead.
func ExtractVersionFromShellCommandOutput ¶ added in v1.0.0
ExtractVersionFromShellCommandOutput extracts version with regex string matching from the given shell command output string.
Types ¶
type CheckVersionParams ¶
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.
type InvalidVersionConstraintErr ¶ added in v1.0.0
InvalidVersionConstraintErr is returned when the VersionConstraint string cannot be parsed.
func (*InvalidVersionConstraintErr) Error ¶ added in v1.0.0
func (e *InvalidVersionConstraintErr) Error() string
func (*InvalidVersionConstraintErr) Unwrap ¶ added in v1.0.0
func (e *InvalidVersionConstraintErr) Unwrap() error
type InvalidVersionFormatErr ¶ added in v1.0.0
InvalidVersionFormatErr is returned when a version string cannot be parsed.
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 ¶ added in v1.0.0
type MissingParamErr struct {
Param string
}
MissingParamErr is returned when a required field in CheckVersionParams is empty.
func (*MissingParamErr) Error ¶ added in v1.0.0
func (e *MissingParamErr) Error() string
type UnsupportedBinaryErr ¶ added in v1.0.0
type UnsupportedBinaryErr struct {
Binary VersionCheckerBinary
}
UnsupportedBinaryErr is returned when [CheckVersionParams.Binary] is set to an unknown VersionCheckerBinary value.
func (*UnsupportedBinaryErr) Error ¶ added in v1.0.0
func (e *UnsupportedBinaryErr) Error() string
type VersionCheckerBinary ¶
type VersionCheckerBinary int
VersionCheckerBinary is an enum for supported version checking.
const ( Docker VersionCheckerBinary = iota Terraform Packer )
List of binaries supported for version checking.
type VersionExtractionErr ¶ 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.
func (*VersionExtractionErr) Error ¶ added in v1.0.0
func (e *VersionExtractionErr) Error() string
type VersionMismatchErr ¶
VersionMismatchErr is returned when a binary's version does not satisfy the given version constraint.
func (*VersionMismatchErr) Error ¶
func (e *VersionMismatchErr) Error() string