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

Conversation

thaJeztah
Copy link
Member

follow-up to #3257

Previously, version: "3" was equivalent to version: "3.0", which
caused confusion for many users, as they expected it to be "3.x".

docker-compose and docker compose (v2) have adopted the compose-spec
(https://compose-spec.io), which no longer has a version field in
the compose file, and always picks the "latest" supported version.

This changes how docker stack interprets "major" version numbers
specified in compose-files:

When only the major version ("3") is specified, it is now equivalent
to "3.x" (latest supported v3 schema).

Compose-files that specify both major and minor version (e.g. "3.0"
or "3.1") continue to use the existing behavior; validation is down-
graded to the specified version and will produce an error if options
are used that are not supported in that schema version. This allows
users to locally verify that a composse-file does not use options
that are not supported in the intended deployment environment (for
example if the deploy environment only supports older versions of
the schema).

- Description for the changelog

- A picture of a cute animal (not mandatory but encouraged)

@thaJeztah
Copy link
Member Author

/cc @ndeloof @ulyssessouza ptal

Copy link
Contributor

@ndeloof ndeloof left a comment

Choose a reason for hiding this comment

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

+10000000

@thaJeztah
Copy link
Member Author

thaJeztah commented Feb 26, 2022

Oh! One test failing; I probably forgot to update one (it's been a while since I made this patch)

=== FAIL: cli/compose/loader TestLoad (0.01s)
     loader_test.go:239: assertion failed: 3.0 (sampleConfig.Version string) != 3.10 (actual.Version string)

Previously, `version: "3"` was equivalent to `version: "3.0"`, which
caused confusion for many users, as they expected it to be "3.x".

docker-compose and docker compose (v2) have adopted the compose-spec
(https://compose-spec.io), which no longer has a version field in
the compose file, and always picks the "latest" supported version.

This changes how `docker stack` interprets "major" version numbers
specified in compose-files:

When only the major version ("3") is specified, it is now equivalent
to "3.x" (latest supported v3 schema).

Compose-files that specify both major and minor version (e.g. "3.0"
or "3.1") continue to use the existing behavior; validation is down-
graded to the specified version and will produce an error if options
are used that are not supported in that schema version. This allows
users to locally verify that a composse-file does not use options
that are not supported in the intended deployment environment (for
example if the deploy environment only supports older versions of
the schema).

Signed-off-by: Sebastiaan van Stijn <[email protected]>
@thaJeztah thaJeztah force-pushed the compose_version_3.x branch from 85ebdc1 to 60c3836 Compare March 1, 2022 08:40
@@ -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

@thaJeztah
Copy link
Member Author

Let's get this one in 👍

@thaJeztah thaJeztah merged commit 6c6203f into docker:master Mar 1, 2022
@thaJeztah thaJeztah deleted the compose_version_3.x branch March 1, 2022 08:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants