mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-08-06 14:04:17 -04:00
cli: add version validation and force flag
Version validation checks that the configured versions are not more than one minor version below the CLI's version. The validation can be disabled using --force. This is necessary for now during development as the CLI does not have a prerelease version, as our images do.
This commit is contained in:
parent
3a7b829107
commit
f204c24174
29 changed files with 590 additions and 61 deletions
51
internal/config/validation_test.go
Normal file
51
internal/config/validation_test.go
Normal file
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
Copyright (c) Edgeless Systems GmbH
|
||||
|
||||
SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
package config
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/edgelesssys/constellation/v2/internal/constants"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
// TestValidateVersionCompatibilityHelper checks that basic version and image short paths are correctly validated.
|
||||
func TestValidateVersionCompatibilityHelper(t *testing.T) {
|
||||
testCases := map[string]struct {
|
||||
cli string
|
||||
target string
|
||||
wantError bool
|
||||
}{
|
||||
"full version works": {
|
||||
cli: "v0.1.0",
|
||||
target: "v0.0.0",
|
||||
},
|
||||
"short path works": {
|
||||
cli: "v0.1.0",
|
||||
target: "ref/main/stream/debug/v0.0.0-pre.0.20230109121528-d24fac00f018",
|
||||
},
|
||||
"minor version difference > 1": {
|
||||
cli: "0.0.0",
|
||||
target: "ref/main/stream/debug/v0.2.0-pre.0.20230109121528-d24fac00f018",
|
||||
wantError: true,
|
||||
},
|
||||
}
|
||||
|
||||
for name, tc := range testCases {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
constants.VersionInfo = tc.cli
|
||||
err := validateVersionCompatibilityHelper("Image", tc.target)
|
||||
if tc.wantError {
|
||||
assert.Error(err)
|
||||
return
|
||||
}
|
||||
assert.NoError(err)
|
||||
})
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue