Skip to content
This repository was archived by the owner on Nov 27, 2023. It is now read-only.

Conversation

@milas
Copy link
Contributor

@milas milas commented Jul 21, 2021

What I did
Currently, compose config --services outputs the services in
a random/non-deterministic order.

In Compose v1, this was implicitly topologically sorted because
the project services were pre-sorted. With compose-go, the
services are unordered, and the WithServices() helper can be
used to iterate in dependency order.

Tests
There wasn't a great way to unit test this without further refactoring
as runServices uses convertOptions::toProject() which will
attempt to load a real Compose file. (AFAICT there aren't really any
existing CLI unit tests.)

If desirable, I can split the function in two so that the project
conversion from opts is separate from the actual logic which can
just take a *types.Project and so would be trivially testable.

(not mandatory) A picture of a cute animal, if possible in relation with what you did
image

Currently, `compose config --services` outputs the services in
a random/non-deterministic order.

In Compose v1, this was implicitly topologically sorted because
the project services were pre-sorted. With `compose-go`, the
services are unordered, and the `WithServices()` helper can be
used to iterate in dependency order.

Signed-off-by: Milas Bowman <milasb@gmail.com>
@milas milas force-pushed the cli-service-order branch from 6604e88 to 1e35245 Compare July 21, 2021 15:11
@ndeloof ndeloof merged commit d993c47 into docker-archive:main Jul 23, 2021
@milas milas deleted the cli-service-order branch July 23, 2021 13:39
@milas
Copy link
Contributor Author

milas commented Jul 23, 2021

Thanks for the quick turnaround! ❤️

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants