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

Describe valid project name on error #362

Merged
merged 3 commits into from
Mar 3, 2023

Conversation

mbland
Copy link
Contributor

@mbland mbland commented Mar 3, 2023

PR #261 changed docker compose behavior to require normalized project names as input, instead of normalizing project names automatically. This landed in compose-spec/compose-go v1.2.5 and docker/compose v2.5.1.

However, the previous error message gave no indication why a name isn't valid. This is surprising for users whose previously working project names no longer work with newer versions of docker compose.

As of compose-spec/compose-spec#314, the spec now contains the text:

Project name MUST contain only lowercase letters, decimal digits,
dashes, and underscores, and MUST begin with a lowercase letter or
decimal digit.

This updated error message provides a concise version of this requirement based on regular expression character range notation.

See also:

PR compose-spec#261 changed `docker compose` behavior to require normalized project
names as input, instead of normalizing project names automatically. This
landed in compose-spec/compose-go v1.2.5 and docker/compose v2.5.1.

However, the previous error message gave no indication why a name isn't
valid.  This is surprising for users whose previously working project
names no longer work with newer versions of `docker compose`.

As of compose-spec/compose-spec#314, the spec now contains the text:

> Project name MUST contain only lowercase letters, decimal digits,
> dashes, and underscores, and MUST begin with a lowercase letter or
> decimal digit.

This updated error message provides a concise version of this
requirement based on regular expression character range notation.

See also:

- compose-spec/compose-spec#311
- docker/compose#9741

Signed-off-by: Mike Bland <mbland@acm.org>
This update landed in compose-spec/compose-spec#314, reflecting the new
project name spec:

> Project name MUST contain only lowercase letters, decimal digits,
> dashes, and underscores, and MUST begin with a lowercase letter or
> decimal digit.

Signed-off-by: Mike Bland <mbland@acm.org>
@mbland mbland force-pushed the project-name-error-message branch from e2729c4 to 226dd79 Compare March 3, 2023 17:09
@mbland
Copy link
Contributor Author

mbland commented Mar 3, 2023

FYI, I force-pushed my branch after CI results showed I hadn't synced schema/compose-spec.json and had a go fmt error in cli/options.go.

This fixes the failure caught by loader/loader_test.go in the CI run for
PR compose-spec#362:

```
--- FAIL: TestFullExample (0.00s)
    loader_test.go:969: assertion failed: error is not nil: name Does not match pattern '^[a-z0-9][a-z0-9_-]*$'
```

Signed-off-by: Mike Bland <mbland@acm.org>
@mbland
Copy link
Contributor Author

mbland commented Mar 3, 2023

Just pushed another commit—I'd missed the loader/loader_test.go breakage. (That's what I get for running go test ./options instead of go test ./...!)

@ndeloof ndeloof merged commit 37ba724 into compose-spec:master Mar 3, 2023
@mbland mbland deleted the project-name-error-message branch March 3, 2023 17:54
mbland added a commit to mbland/docs that referenced this pull request Mar 3, 2023
These changes reflect current `docker compose` behavior regarding
acceptable project names.

compose-spec/compose-go#261 changed `docker compose` behavior to require
normalized project names as input, instead of normalizing project names
automatically. This landed in compose-spec/compose-go v1.2.5 and
docker/compose v2.5.1.

compose-spec/compose-spec#314 updated the compose spec, and
compose-spec/compose-go#362 added information to the error message
specifying the correct project name format.

Local development URLs:
- http://localhost:4000/compose/reference/#use--p-to-specify-a-project-name
- http://localhost:4000/compose/environment-variables/envvars/#compose_project_name
- http://localhost:4000/engine/reference/commandline/compose/#use--p-to-specify-a-project-name

Production URLs:
- https://docs.docker.com/compose/reference/#use--p-to-specify-a-project-name
- https://docs.docker.com/compose/environment-variables/envvars/#compose_project_name
- https://docs.docker.com/engine/reference/commandline/compose/#use--p-to-specify-a-project-name

Signed-off-by: Mike Bland <mbland@acm.org>
mbland added a commit to mbland/docs that referenced this pull request Mar 19, 2023
These changes reflect current `docker compose` behavior regarding
acceptable project names.

compose-spec/compose-go#261 changed `docker compose` behavior to require
normalized project names as input, instead of normalizing project names
automatically. This landed in compose-spec/compose-go v1.2.5 and
docker/compose v2.5.1.

compose-spec/compose-spec#314 updated the compose spec, and
compose-spec/compose-go#362 added information to the error message
specifying the correct project name format.

Local development URLs:
- http://localhost:4000/compose/reference/#use--p-to-specify-a-project-name
- http://localhost:4000/compose/environment-variables/envvars/#compose_project_name
- http://localhost:4000/engine/reference/commandline/compose/#use--p-to-specify-a-project-name

Production URLs:
- https://docs.docker.com/compose/reference/#use--p-to-specify-a-project-name
- https://docs.docker.com/compose/environment-variables/envvars/#compose_project_name
- https://docs.docker.com/engine/reference/commandline/compose/#use--p-to-specify-a-project-name

Signed-off-by: Mike Bland <mbland@acm.org>
mbland added a commit to mbland/docs that referenced this pull request Mar 19, 2023
These changes reflect updated `docker compose` behavior regarding
acceptable project names.

compose-spec/compose-go#261 changed `docker compose` behavior to require
normalized project names as input when using `-p`. Previously `docker
compose` normalized project names automatically, leading to errors for
some users after the change landed in compose-spec/compose-go v1.2.5 and
docker/compose v2.5.1.

compose-spec/compose-spec#314 updated the compose spec, effectively
enforcing the same constraint for the `name:` config file property.
compose-spec/compose-go#362 added information to the error message
specifying the correct project name format. compose-spec/compose-go#364
added enforcement of the new project name requirements for all project
name mechanisms (`-p`, `name:`, `COMPOSE_PROJECT_NAME`, project dir,
working dir).

Local development URLs:
- http://localhost:4000/compose/reference/#use--p-to-specify-a-project-name
- http://localhost:4000/compose/environment-variables/envvars/#compose_project_name
- http://localhost:4000/engine/reference/commandline/compose/#use--p-to-specify-a-project-name

Production URLs:
- https://docs.docker.com/compose/reference/#use--p-to-specify-a-project-name
- https://docs.docker.com/compose/environment-variables/envvars/#compose_project_name
- https://docs.docker.com/engine/reference/commandline/compose/#use--p-to-specify-a-project-name

Signed-off-by: Mike Bland <mbland@acm.org>
aevesdocker pushed a commit to docker/docs that referenced this pull request Mar 22, 2023
* Add detailed project name requirements, mechanisms

These changes reflect updated `docker compose` behavior regarding
acceptable project names.

compose-spec/compose-go#261 changed `docker compose` behavior to require
normalized project names as input when using `-p`. Previously `docker
compose` normalized project names automatically, leading to errors for
some users after the change landed in compose-spec/compose-go v1.2.5 and
docker/compose v2.5.1.

compose-spec/compose-spec#314 updated the compose spec, effectively
enforcing the same constraint for the `name:` config file property.
compose-spec/compose-go#362 added information to the error message
specifying the correct project name format. compose-spec/compose-go#364
added enforcement of the new project name requirements for all project
name mechanisms (`-p`, `name:`, `COMPOSE_PROJECT_NAME`, project dir,
working dir).

Local development URLs:
- http://localhost:4000/compose/reference/#use--p-to-specify-a-project-name
- http://localhost:4000/compose/environment-variables/envvars/#compose_project_name
- http://localhost:4000/engine/reference/commandline/compose/#use--p-to-specify-a-project-name

Production URLs:
- https://docs.docker.com/compose/reference/#use--p-to-specify-a-project-name
- https://docs.docker.com/compose/environment-variables/envvars/#compose_project_name
- https://docs.docker.com/engine/reference/commandline/compose/#use--p-to-specify-a-project-name

Signed-off-by: Mike Bland <mbland@acm.org>

* Revert _data/compose-cli/docker_compose.yaml

This reverts part of commit 9ce29a8.

As @glours noted in the review of #16915, this content comes from the
upstream docker/compose repo. He's opened docker/compose#10390 to apply
the update there instead.

Signed-off-by: Mike Bland <mbland@acm.org>

---------

Signed-off-by: Mike Bland <mbland@acm.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants