Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cli/compose/schema: make version: "3" equivalent to "3.x" (latest) #3445

Merged
merged 1 commit into from
Mar 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cli/compose/loader/loader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ func strPtr(val string) *string {
}

var sampleConfig = types.Config{
Version: "3.0",
Version: "3.10",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was the config I forgot to update that made the test fail; all green now

Services: []types.ServiceConfig{
{
Name: "foo",
Expand Down
7 changes: 3 additions & 4 deletions cli/compose/schema/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion cli/compose/schema/schema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
Expand All @@ -100,6 +99,7 @@ func TestValidateCredentialSpecs(t *testing.T) {
{version: "3.8"},
{version: "3.9"},
{version: "3.10"},
{version: "3"},
{version: ""},
}

Expand Down