Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make extra_hosts values uniques #685

Merged
merged 1 commit into from
Sep 26, 2024

Conversation

glours
Copy link
Collaborator

@glours glours commented Sep 24, 2024

Issue occurred when you have an extra_hosts value defined in the main config file and you have an extends of the service with the exact same name without any additional extra_hosts config

Fixes docker/compose#12155

@glours glours requested a review from ndeloof as a code owner September 24, 2024 12:55
@glours glours requested a review from jhrotko September 24, 2024 12:55
@glours glours self-assigned this Sep 24, 2024
@@ -50,6 +50,7 @@ func init() {
unique["services.*.environment"] = keyValueIndexer
unique["services.*.env_file"] = envFileIndexer
unique["services.*.expose"] = exposeIndexer
unique["services.*.extra_hosts"] = keyValueIndexer
Copy link
Collaborator

Choose a reason for hiding this comment

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

:-1
this was intentionally removed, as extra_hosts can be set multiple time per host with distinct IPs
see docker/compose#12088

Copy link
Collaborator

Choose a reason for hiding this comment

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

one option could be to drop strictly equal lines, which somehow relax the json schema unicity rule, which doesn't bring any value here

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ok, I'll build a custom indexer

@glours glours force-pushed the extra_hosts-unicity branch from 38f94a7 to 6523dd3 Compare September 26, 2024 08:50
Comment on lines +169 to +178
// Rewrite content of left slice to remove duplicate elements
i := 0
for _, v := range left {
if !slices.Contains(right, v) {
left[i] = v
i++
}
}
// keep only not duplicated elements from left slice
left = left[:i]
Copy link
Collaborator

Choose a reason for hiding this comment

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

you can use https://pkg.go.dev/slices#Compact to remove duplicates from a slice

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Nope I tried it and it works only with consecutive values unfortunately

@glours glours force-pushed the extra_hosts-unicity branch from 6523dd3 to 8231c19 Compare September 26, 2024 09:08
@glours glours requested a review from ndeloof September 26, 2024 09:15
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
@glours glours force-pushed the extra_hosts-unicity branch from 8231c19 to 602e5ba Compare September 26, 2024 14:09
@glours glours enabled auto-merge (rebase) September 26, 2024 14:09
@glours glours merged commit d3fd7d9 into compose-spec:main Sep 26, 2024
8 checks passed
@Nek-
Copy link

Nek- commented Oct 8, 2024

Thanks for the bugfix! Is there an estimated date for a new release? 😅

@jhrotko
Copy link
Collaborator

jhrotko commented Oct 9, 2024

@Nek- We are not sure, but should be around in 1~2 weeks

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.

[BUG] <extra_hosts array items[0,1] must be unique>
4 participants