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

Nested docker-compose configurations don't inherit composeFiles anymore #307

Open
thijslemmens opened this issue May 3, 2023 · 3 comments
Labels
has-jira-ticket Corresponding ticket has been opened in the Xenit Jira for planning

Comments

@thijslemmens
Copy link
Contributor

No description provided.

@vierbergenlars vierbergenlars added the has-jira-ticket Corresponding ticket has been opened in the Xenit Jira for planning label May 16, 2023
@vierbergenlars
Copy link
Member

Are you sure that this was ever supported?

The avast docker-compose plugin has this in their docs:

Configuration of the nested settings defaults to the main dockerCompose settings (declared before the nested settings), except following properties: projectName, startedServices, useComposeFiles, scale, captureContainersOutputToFile, captureContainersOutputToFiles, composeLogToFile, containerLogToDir, pushServices

And that statement is there since version 0.12.2 (the behavior even earlier)

@thijslemmens
Copy link
Contributor Author

It used to work with +=, now with add it does not anymore. I'm not sure that it works with the vanilla dockerCompose plugin. It's in our backlog to check it out.

@vierbergenlars
Copy link
Member

I tested with all plugin versions from 5.0.2 (the first version that introduced nested support) until 5.4.0 (the current latest version)

I could not find any version that actually appends additional items to the list of the composeFiles when creating a nested configuration.

By searching in all repositories, I can not find a single use of this behavior. However, I do see a pattern that can be mistaken for this behavior:

Test code
package eu.xenit.gradle.docker.compose;

import static org.junit.Assert.assertEquals;

import com.avast.gradle.dockercompose.ComposeSettings;
import java.util.ArrayList;
import java.util.List;
import org.gradle.api.Project;
import org.gradle.testfixtures.ProjectBuilder;
import org.junit.Test;

public class DockerComposeExtensionOverrideTest {
    @Test
    public void nestedContainsParentComposeFiles() {
        Project project = ProjectBuilder.builder().build();

        project.getPluginManager().apply(DockerComposePlugin.class);

        project.getExtensions().configure(DockerComposeExtensionOverride.class, dockerCompose -> {
            dockerCompose.getUseComposeFiles().add("docker-compose-1.yml");

            ((ComposeSettings)dockerCompose.methodMissing("sub", new Object[0])).getUseComposeFiles().add("docker-compose-2.yml");
        });

        List<String> composeFiles = project.getExtensions().getByType(DockerComposeExtensionOverride.class).getUseComposeFiles();
        List<String> subComposeFiles = ((ComposeSettings)project.getExtensions().getByType(DockerComposeExtensionOverride.class).propertyMissing("sub")).getUseComposeFiles();

        assertEquals(new ArrayList<String>() {{
            add("docker-compose.yml");
            add("docker-compose-1.yml");
        }}, composeFiles);

        assertEquals(new ArrayList<String>() {{
            add("docker-compose.yml");
            add("docker-compose-1.yml");
            add("docker-compose-2.yml");
        }}, subComposeFiles);
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
has-jira-ticket Corresponding ticket has been opened in the Xenit Jira for planning
Projects
None yet
Development

No branches or pull requests

2 participants