mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-02-17 13:24:21 -05: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 {
|
if cliMajor != targetMajor {
|
||||||
return ErrMajorMismatch
|
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
|
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.
|
||||||
|
@ -87,7 +87,7 @@ func TestNextMinorVersion(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCLIWith(t *testing.T) {
|
func TestBinaryWith(t *testing.T) {
|
||||||
testCases := map[string]struct {
|
testCases := map[string]struct {
|
||||||
cli string
|
cli string
|
||||||
target string
|
target string
|
||||||
@ -107,7 +107,7 @@ func TestCLIWith(t *testing.T) {
|
|||||||
target: "v1.2",
|
target: "v1.2",
|
||||||
wantError: true,
|
wantError: true,
|
||||||
},
|
},
|
||||||
"a has to be the newer version": {
|
"cli has to be the newer version": {
|
||||||
cli: "v2.4.0",
|
cli: "v2.4.0",
|
||||||
target: "v2.5.0",
|
target: "v2.5.0",
|
||||||
wantError: true,
|
wantError: true,
|
||||||
@ -116,7 +116,7 @@ func TestCLIWith(t *testing.T) {
|
|||||||
cli: "v2.5.0-pre",
|
cli: "v2.5.0-pre",
|
||||||
target: "v2.4.0",
|
target: "v2.4.0",
|
||||||
},
|
},
|
||||||
"pre prelease version ordering is correct #2": {
|
"pre prelease versions are not forward compatible": {
|
||||||
cli: "v2.4.0",
|
cli: "v2.4.0",
|
||||||
target: "v2.5.0-pre",
|
target: "v2.5.0-pre",
|
||||||
wantError: true,
|
wantError: true,
|
||||||
@ -125,11 +125,19 @@ func TestCLIWith(t *testing.T) {
|
|||||||
cli: "v2.6.0-pre",
|
cli: "v2.6.0-pre",
|
||||||
target: "v2.6.0-pre",
|
target: "v2.6.0-pre",
|
||||||
},
|
},
|
||||||
"pseudo version is newer than first pre release": {
|
"patch versions are forward compatible": {
|
||||||
cli: "v2.6.0-pre",
|
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",
|
target: "v2.6.0-pre.0.20230125085856-aaaaaaaaaaaa",
|
||||||
wantError: true,
|
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 {
|
for name, tc := range testCases {
|
||||||
|
@ -358,6 +358,14 @@ func validateVersionCompatibilityHelper(fieldName string, configuredVersion stri
|
|||||||
configuredVersion = imageVersion.Version
|
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)
|
return compatibility.BinaryWith(configuredVersion)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user