Merge pull request #3445 from thaJeztah/compose_version_3.x

cli/compose/schema: make version: "3" equivalent to "3.x" (latest)
This commit is contained in:
Sebastiaan van Stijn 2022-03-01 09:53:24 +01:00 committed by GitHub
commit 6c6203fcc5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 6 deletions

View File

@ -180,7 +180,7 @@ func strPtr(val string) *string {
}
var sampleConfig = types.Config{
Version: "3.0",
Version: "3.10",
Services: []types.ServiceConfig{
{
Name: "foo",

View File

@ -40,7 +40,8 @@ func init() {
}
// Version returns the version of the config, defaulting to the latest "3.x"
// version (3.10).
// version (3.10). If only the major version "3" is specified, it is used as
// version "3.x" and returns the default version (latest 3.x).
func Version(config map[string]interface{}) string {
version, ok := config[versionField]
if !ok {
@ -51,10 +52,8 @@ func Version(config map[string]interface{}) string {
func normalizeVersion(version string) string {
switch version {
case "":
case "", "3":
return defaultVersion
case "3":
return "3.0"
default:
return version
}

View File

@ -88,7 +88,6 @@ func TestValidateCredentialSpecs(t *testing.T) {
version string
expectedErr string
}{
{version: "3", expectedErr: "credential_spec"},
{version: "3.0", expectedErr: "credential_spec"},
{version: "3.1", expectedErr: "credential_spec"},
{version: "3.2", expectedErr: "credential_spec"},
@ -100,6 +99,7 @@ func TestValidateCredentialSpecs(t *testing.T) {
{version: "3.8"},
{version: "3.9"},
{version: "3.10"},
{version: "3"},
{version: ""},
}