Skip to content

Commit

Permalink
Merge pull request #110 from iamdanfox/better-builder
Browse files Browse the repository at this point in the history
Better builder class in DockerComposeRule
  • Loading branch information
iamdanfox authored Sep 30, 2016
2 parents 84ecb03 + 56306c5 commit 5ce6b1a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 19 deletions.
28 changes: 11 additions & 17 deletions src/main/java/com/palantir/docker/compose/DockerComposeRule.java
Original file line number Diff line number Diff line change
Expand Up @@ -173,49 +173,43 @@ public String run(DockerComposeRunOption options, String containerName,
return dockerCompose().run(options, containerName, arguments);
}

public static ImmutableDockerComposeRule.Builder builder() {
return ImmutableDockerComposeRule.builder();
public static Builder builder() {
return new Builder();
}

public abstract static class Builder {
public static class Builder extends ImmutableDockerComposeRule.Builder {

public abstract ImmutableDockerComposeRule.Builder files(DockerComposeFiles files);

public ImmutableDockerComposeRule.Builder file(String dockerComposeYmlFile) {
public Builder file(String dockerComposeYmlFile) {
return files(DockerComposeFiles.from(dockerComposeYmlFile));
}

public abstract ImmutableDockerComposeRule.Builder logCollector(LogCollector logCollector);

public ImmutableDockerComposeRule.Builder saveLogsTo(String path) {
public Builder saveLogsTo(String path) {
return logCollector(FileLogCollector.fromPath(path));
}

public abstract ImmutableDockerComposeRule.Builder addClusterWait(ClusterWait clusterWait);

public ImmutableDockerComposeRule.Builder waitingForService(String serviceName, HealthCheck<Container> healthCheck) {
public Builder waitingForService(String serviceName, HealthCheck<Container> healthCheck) {
return waitingForService(serviceName, healthCheck, DEFAULT_TIMEOUT);
}

public ImmutableDockerComposeRule.Builder waitingForService(String serviceName, HealthCheck<Container> healthCheck, ReadableDuration timeout) {
public Builder waitingForService(String serviceName, HealthCheck<Container> healthCheck, ReadableDuration timeout) {
ClusterHealthCheck clusterHealthCheck = serviceHealthCheck(serviceName, healthCheck);
return addClusterWait(new ClusterWait(clusterHealthCheck, timeout));
}

public ImmutableDockerComposeRule.Builder waitingForServices(List<String> services, HealthCheck<List<Container>> healthCheck) {
public Builder waitingForServices(List<String> services, HealthCheck<List<Container>> healthCheck) {
return waitingForServices(services, healthCheck, DEFAULT_TIMEOUT);
}

public ImmutableDockerComposeRule.Builder waitingForServices(List<String> services, HealthCheck<List<Container>> healthCheck, ReadableDuration timeout) {
public Builder waitingForServices(List<String> services, HealthCheck<List<Container>> healthCheck, ReadableDuration timeout) {
ClusterHealthCheck clusterHealthCheck = serviceHealthCheck(services, healthCheck);
return addClusterWait(new ClusterWait(clusterHealthCheck, timeout));
}

public ImmutableDockerComposeRule.Builder waitingForHostNetworkedPort(int port, HealthCheck<DockerPort> healthCheck) {
public Builder waitingForHostNetworkedPort(int port, HealthCheck<DockerPort> healthCheck) {
return waitingForHostNetworkedPort(port, healthCheck, DEFAULT_TIMEOUT);
}

public ImmutableDockerComposeRule.Builder waitingForHostNetworkedPort(int port, HealthCheck<DockerPort> healthCheck, ReadableDuration timeout) {
public Builder waitingForHostNetworkedPort(int port, HealthCheck<DockerPort> healthCheck, ReadableDuration timeout) {
ClusterHealthCheck clusterHealthCheck = transformingHealthCheck(cluster -> new DockerPort(cluster.ip(), port, port), healthCheck);
return addClusterWait(new ClusterWait(clusterHealthCheck, timeout));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/
package com.palantir.docker.compose;

import com.palantir.docker.compose.ImmutableDockerComposeRule.Builder;
import com.palantir.docker.compose.configuration.DockerComposeFiles;
import com.palantir.docker.compose.configuration.ProjectName;
import com.palantir.docker.compose.connection.Container;
Expand All @@ -32,7 +31,7 @@
*/
@Deprecated
public class DockerCompositionBuilder {
private final Builder builder;
private final DockerComposeRule.Builder builder;

public DockerCompositionBuilder() {
this.builder = DockerComposeRule.builder();
Expand Down

0 comments on commit 5ce6b1a

Please sign in to comment.