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

Print services in dependency order #1937

Merged
merged 1 commit into from
Jul 23, 2021

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>
@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