config: improve error message for outdated CLIs

This commit is contained in:
Otto Bittner 2023-02-15 10:18:49 +01:00
parent e600795239
commit 2a0b56f7b8
2 changed files with 7 additions and 3 deletions

View file

@ -22,9 +22,11 @@ var (
// ErrMajorMismatch signals that the major version of two compared versions don't match.
ErrMajorMismatch = errors.New("missmatching major version")
// ErrMinorDrift signals that the minor version of two compared versions are further apart than one.
ErrMinorDrift = errors.New("target version needs to be equal or up to one minor version higher")
ErrMinorDrift = errors.New("version difference larger than one minor version")
// ErrSemVer signals that a given version does not adhere to the Semver syntax.
ErrSemVer = errors.New("invalid semantic version")
// ErrOutdatedCLI signals that the configured version is newer than the CLI. This is not allowed.
ErrOutdatedCLI = errors.New("target version newer than cli version")
)
// EnsurePrefixV returns the input string prefixed with the letter "v", if the string doesn't already start with that letter.
@ -89,7 +91,7 @@ func BinaryWith(target string) error {
return ErrMajorMismatch
}
if semver.Compare(binaryVersion, target) == -1 {
return ErrMinorDrift
return ErrOutdatedCLI
}
// Abort if minor version drift between CLI and versionA value is greater than 1.
if cliMinor-targetMinor > 1 {