Skip to content

filter depends_on services when required is not set#432

Merged
glours merged 1 commit intocompose-spec:masterfrom
glours:filter-non-required-dependencies
Jul 18, 2023
Merged

filter depends_on services when required is not set#432
glours merged 1 commit intocompose-spec:masterfrom
glours:filter-non-required-dependencies

Conversation

@glours
Copy link
Copy Markdown
Collaborator

@glours glours commented Jul 11, 2023

If a depends_on is marked as non-required, we shouldn't return an error if not found

@glours glours self-assigned this Jul 11, 2023
@glours glours requested a review from ndeloof as a code owner July 11, 2023 09:52
@glours glours requested review from milas and ulyssessouza and removed request for milas and ulyssessouza July 11, 2023 09:52
@glours glours marked this pull request as draft July 11, 2023 10:13
@glours glours force-pushed the filter-non-required-dependencies branch 10 times, most recently from 73afd7f to 39e2739 Compare July 13, 2023 22:33
@glours glours marked this pull request as ready for review July 13, 2023 22:36
@glours glours requested review from laurazard and milas July 13, 2023 22:37
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
@glours glours force-pushed the filter-non-required-dependencies branch from 39e2739 to 27cae8c Compare July 13, 2023 22:41
Copy link
Copy Markdown
Member

@laurazard laurazard left a comment

Choose a reason for hiding this comment

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

LGTM, just left a suggestion

func (p *Project) GetServices(names ...string) (Services, error) {
services, servicesNotFound := p.getServicesByNames(names...)
if len(servicesNotFound) > 0 {
return services, fmt.Errorf("no such service: %s", servicesNotFound[0])
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: we should return all not found services at once, otherwise if people have multiple services missing they'll have to go

$ compose up
[no such service: foo]

<fixes config>

$ compose up
[no such service: bar]

<yells at computer and fixes things again>

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

As this method is public, I didn't want to introduce a breaking change by adding the support depends_on.required attribute, so this implementation keep the same behaviour as the current one.
I agree we should return all the missing service at once, but I prefer to do that in a dedicated PR if this is fine for you @laurazard?

@glours glours merged commit 4c1837e into compose-spec:master Jul 18, 2023
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.

3 participants