mirror of
https://github.com/edgelesssys/constellation.git
synced 2024-10-01 01:36:09 -04:00
compatibility: allow newer patch versions for images
Validation incorrectly prevented newer patch versions for images.
This commit is contained in:
parent
2a0b56f7b8
commit
6f9d76dd6e
@ -90,7 +90,8 @@ func BinaryWith(target string) error {
|
||||
if cliMajor != targetMajor {
|
||||
return ErrMajorMismatch
|
||||
}
|
||||
if semver.Compare(binaryVersion, target) == -1 {
|
||||
// For images we allow newer patch versions, therefore this only checks the minor version.
|
||||
if semver.Compare(semver.MajorMinor(binaryVersion), semver.MajorMinor(target)) == -1 {
|
||||
return ErrOutdatedCLI
|
||||
}
|
||||
// Abort if minor version drift between CLI and versionA value is greater than 1.
|
||||
|
@ -87,7 +87,7 @@ func TestNextMinorVersion(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestCLIWith(t *testing.T) {
|
||||
func TestBinaryWith(t *testing.T) {
|
||||
testCases := map[string]struct {
|
||||
cli string
|
||||
target string
|
||||
@ -107,7 +107,7 @@ func TestCLIWith(t *testing.T) {
|
||||
target: "v1.2",
|
||||
wantError: true,
|
||||
},
|
||||
"a has to be the newer version": {
|
||||
"cli has to be the newer version": {
|
||||
cli: "v2.4.0",
|
||||
target: "v2.5.0",
|
||||
wantError: true,
|
||||
@ -116,7 +116,7 @@ func TestCLIWith(t *testing.T) {
|
||||
cli: "v2.5.0-pre",
|
||||
target: "v2.4.0",
|
||||
},
|
||||
"pre prelease version ordering is correct #2": {
|
||||
"pre prelease versions are not forward compatible": {
|
||||
cli: "v2.4.0",
|
||||
target: "v2.5.0-pre",
|
||||
wantError: true,
|
||||
@ -125,11 +125,19 @@ func TestCLIWith(t *testing.T) {
|
||||
cli: "v2.6.0-pre",
|
||||
target: "v2.6.0-pre",
|
||||
},
|
||||
"pseudo version is newer than first pre release": {
|
||||
cli: "v2.6.0-pre",
|
||||
"patch versions are forward compatible": {
|
||||
cli: "v2.6.0",
|
||||
target: "v2.6.1",
|
||||
},
|
||||
"pseudo versions are not forward compatible": {
|
||||
cli: "v2.5.0",
|
||||
target: "v2.6.0-pre.0.20230125085856-aaaaaaaaaaaa",
|
||||
wantError: true,
|
||||
},
|
||||
"pseudo version is newer than first pre release": {
|
||||
cli: "v2.6.0-pre",
|
||||
target: "v2.6.0-pre.0.20230125085856-aaaaaaaaaaaa",
|
||||
},
|
||||
}
|
||||
|
||||
for name, tc := range testCases {
|
||||
|
@ -358,6 +358,14 @@ func validateVersionCompatibilityHelper(fieldName string, configuredVersion stri
|
||||
configuredVersion = imageVersion.Version
|
||||
}
|
||||
|
||||
if fieldName == "MicroserviceVersion" {
|
||||
cliVersion := compatibility.EnsurePrefixV(constants.VersionInfo)
|
||||
serviceVersion := compatibility.EnsurePrefixV(configuredVersion)
|
||||
if semver.Compare(cliVersion, serviceVersion) == -1 {
|
||||
return fmt.Errorf("the CLI's version (%s) is older than the configured version (%s)", cliVersion, serviceVersion)
|
||||
}
|
||||
}
|
||||
|
||||
return compatibility.BinaryWith(configuredVersion)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user