Skip to content

add support of depends_on.required attribute#10792

Merged
glours merged 2 commits intodocker:v2from
glours:add-depends_on-required
Jul 19, 2023
Merged

add support of depends_on.required attribute#10792
glours merged 2 commits intodocker:v2from
glours:add-depends_on-required

Conversation

@glours
Copy link
Copy Markdown
Contributor

@glours glours commented Jul 10, 2023

What I did
Add support of depends_on.required attribute

Related issue
N/A

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

@glours glours force-pushed the add-depends_on-required branch from c70bb66 to 679eec6 Compare July 10, 2023 16:30
@glours glours self-assigned this Jul 10, 2023
@glours glours force-pushed the add-depends_on-required branch from 679eec6 to f8aa456 Compare July 10, 2023 17:13
@codecov
Copy link
Copy Markdown

codecov Bot commented Jul 10, 2023

Codecov Report

Patch coverage: 67.74% and project coverage change: +0.19 🎉

Comparison is base (0938c7e) 59.25% compared to head (2d16a05) 59.44%.

Additional details and impacted files
@@            Coverage Diff             @@
##               v2   #10792      +/-   ##
==========================================
+ Coverage   59.25%   59.44%   +0.19%     
==========================================
  Files         115      115              
  Lines        9869     9896      +27     
==========================================
+ Hits         5848     5883      +35     
+ Misses       3430     3425       -5     
+ Partials      591      588       -3     
Impacted Files Coverage Δ
pkg/compose/restart.go 78.04% <ø> (ø)
pkg/compose/convergence.go 70.03% <54.54%> (+1.14%) ⬆️
pkg/compose/compose.go 61.11% <100.00%> (+0.21%) ⬆️
pkg/compose/create.go 59.18% <100.00%> (+0.04%) ⬆️
pkg/compose/dependencies.go 88.77% <100.00%> (+1.53%) ⬆️
pkg/compose/start.go 61.75% <100.00%> (+0.17%) ⬆️

... and 2 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@glours glours force-pushed the add-depends_on-required branch 2 times, most recently from 9b2a58f to 8537832 Compare July 18, 2023 09:19
@glours glours force-pushed the add-depends_on-required branch 2 times, most recently from 518fdac to 09cebc9 Compare July 18, 2023 10:03
@glours glours marked this pull request as ready for review July 18, 2023 10:19
@glours glours force-pushed the add-depends_on-required branch from 09cebc9 to 7cc466a Compare July 18, 2023 11:47
@glours glours marked this pull request as draft July 18, 2023 12:05
@glours glours force-pushed the add-depends_on-required branch from 7cc466a to e4671e5 Compare July 18, 2023 12:19
@glours glours marked this pull request as ready for review July 18, 2023 12:30
@glours glours requested review from milas and ndeloof July 18, 2023 12:30
Comment thread pkg/compose/compose.go Outdated
Comment thread pkg/compose/convergence.go Outdated
Comment thread pkg/compose/create.go Outdated
Copy link
Copy Markdown
Contributor

@milas milas left a comment

Choose a reason for hiding this comment

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

Overall LGTM. I realize I missed the boat on compose-spec/compose-spec#382 😅 but I do wonder if optional: true would be better semantically?

It's a bit weird to have the default/absence of a boolean field be true IMO 😬

Comment thread pkg/compose/compose.go Outdated
Comment thread pkg/compose/restart.go Outdated
Comment thread pkg/e2e/up_test.go Outdated
Comment on lines +164 to +167
res := c.RunDockerComposeCmd(t, "-f", "./fixtures/dependencies/deps-not-required.yaml", "--project-name", projectName,
"up", "-d")
assert.Assert(t, strings.Contains(res.Combined(), "foo"), res.Combined())
assert.Assert(t, !strings.Contains(res.Combined(), "bar"), res.Combined())
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

From compose-spec/compose-spec#382:

Compose only warns you when the dependency service isn't started or available.

❯ docker compose up
[+] Running 2/0
 ✔ Network required_default  Created                                                                                                                  0.0s
 ✔ Container required-foo-1  Created                                                                                                                  0.0s
Attaching to required-foo-1
required-foo-1  | foo
required-foo-1 exited with code 0

Shouldn't there be a warning "foo has optional dependency on bar which was not selected by active profiles" or something?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Right!

@glours glours force-pushed the add-depends_on-required branch 3 times, most recently from 8041b68 to 4e89b87 Compare July 18, 2023 16:42
@glours glours force-pushed the add-depends_on-required branch from 4e89b87 to c6efc63 Compare July 18, 2023 21:13
@glours glours force-pushed the add-depends_on-required branch from c6efc63 to 2d16a05 Compare July 18, 2023 21:45
Copy link
Copy Markdown
Contributor

@milas milas 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 a note: I do think we could do some future CLI work on the output to make startup around dependencies in particular clearer, e.g. I'd still love it if here we could convey "foo launched without bar because not-required profile is not active".

@glours glours deleted the add-depends_on-required branch June 30, 2025 21:04
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