Skip to content

Commit 6c6203f

Browse files
authored
Merge pull request #3445 from thaJeztah/compose_version_3.x
cli/compose/schema: make version: "3" equivalent to "3.x" (latest)
2 parents 8667ccd + 60c3836 commit 6c6203f

3 files changed

Lines changed: 5 additions & 6 deletions

File tree

cli/compose/loader/loader_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ func strPtr(val string) *string {
180180
}
181181

182182
var sampleConfig = types.Config{
183-
Version: "3.0",
183+
Version: "3.10",
184184
Services: []types.ServiceConfig{
185185
{
186186
Name: "foo",

cli/compose/schema/schema.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ func init() {
4040
}
4141

4242
// Version returns the version of the config, defaulting to the latest "3.x"
43-
// version (3.10).
43+
// version (3.10). If only the major version "3" is specified, it is used as
44+
// version "3.x" and returns the default version (latest 3.x).
4445
func Version(config map[string]interface{}) string {
4546
version, ok := config[versionField]
4647
if !ok {
@@ -51,10 +52,8 @@ func Version(config map[string]interface{}) string {
5152

5253
func normalizeVersion(version string) string {
5354
switch version {
54-
case "":
55+
case "", "3":
5556
return defaultVersion
56-
case "3":
57-
return "3.0"
5857
default:
5958
return version
6059
}

cli/compose/schema/schema_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ func TestValidateCredentialSpecs(t *testing.T) {
8888
version string
8989
expectedErr string
9090
}{
91-
{version: "3", expectedErr: "credential_spec"},
9291
{version: "3.0", expectedErr: "credential_spec"},
9392
{version: "3.1", expectedErr: "credential_spec"},
9493
{version: "3.2", expectedErr: "credential_spec"},
@@ -100,6 +99,7 @@ func TestValidateCredentialSpecs(t *testing.T) {
10099
{version: "3.8"},
101100
{version: "3.9"},
102101
{version: "3.10"},
102+
{version: "3"},
103103
{version: ""},
104104
}
105105

0 commit comments

Comments
 (0)