mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-08-06 14:04:17 -04:00
config: improve error message for outdated CLIs
This commit is contained in:
parent
e600795239
commit
2a0b56f7b8
2 changed files with 7 additions and 3 deletions
|
@ -22,9 +22,11 @@ var (
|
||||||
// ErrMajorMismatch signals that the major version of two compared versions don't match.
|
// ErrMajorMismatch signals that the major version of two compared versions don't match.
|
||||||
ErrMajorMismatch = errors.New("missmatching major version")
|
ErrMajorMismatch = errors.New("missmatching major version")
|
||||||
// ErrMinorDrift signals that the minor version of two compared versions are further apart than one.
|
// 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 signals that a given version does not adhere to the Semver syntax.
|
||||||
ErrSemVer = errors.New("invalid semantic version")
|
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.
|
// 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
|
return ErrMajorMismatch
|
||||||
}
|
}
|
||||||
if semver.Compare(binaryVersion, target) == -1 {
|
if semver.Compare(binaryVersion, target) == -1 {
|
||||||
return ErrMinorDrift
|
return ErrOutdatedCLI
|
||||||
}
|
}
|
||||||
// Abort if minor version drift between CLI and versionA value is greater than 1.
|
// Abort if minor version drift between CLI and versionA value is greater than 1.
|
||||||
if cliMinor-targetMinor > 1 {
|
if cliMinor-targetMinor > 1 {
|
||||||
|
|
|
@ -328,7 +328,9 @@ func translateVersionCompatibilityError(ut ut.Translator, fe validator.FieldErro
|
||||||
case errors.Is(err, compatibility.ErrMajorMismatch):
|
case errors.Is(err, compatibility.ErrMajorMismatch):
|
||||||
msg = fmt.Sprintf("the CLI's major version (%s) has to match your configured major version (%s)", constants.VersionInfo, fe.Value().(string))
|
msg = fmt.Sprintf("the CLI's major version (%s) has to match your configured major version (%s)", constants.VersionInfo, fe.Value().(string))
|
||||||
case errors.Is(err, compatibility.ErrMinorDrift):
|
case errors.Is(err, compatibility.ErrMinorDrift):
|
||||||
msg = fmt.Sprintf("only the CLI (%s) can be up to one minor version newer than the configured version (%s)", constants.VersionInfo, fe.Value().(string))
|
msg = fmt.Sprintf("the CLI's minor version (%s) and the configured version (%s) are more than one minor version apart", constants.VersionInfo, fe.Value().(string))
|
||||||
|
case errors.Is(err, compatibility.ErrOutdatedCLI):
|
||||||
|
msg = fmt.Sprintf("the CLI's version (%s) is older than the configured version (%s)", constants.VersionInfo, fe.Value().(string))
|
||||||
default:
|
default:
|
||||||
msg = err.Error()
|
msg = err.Error()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue