Skip to content

Conversation

glours
Copy link
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 ulyssessouza and milas 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 milas and laurazard 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
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

@@ -102,10 +104,19 @@ func (p *Project) ConfigNames() []string {

// GetServices retrieve services by names, or return all services if no name specified
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
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
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