@Override public Process execute(String... commands) throws IOException { List<String> args = ImmutableList.<String>builder() .add(dockerPath()) .add(commands) .build(); return dockerConfiguration().configuredDockerComposeProcess() .command(args) .redirectErrorStream(true) .start(); }
private DockerExecutable dockerExecutable() { if (executable == null) { executable = DockerExecutable.builder().dockerConfiguration(this.machine()).build(); } return executable; }
@Test public void call_docker_network_ls() throws IOException, InterruptedException { String lsOutput = "0.0.0.0:7000->7000/tcp"; when(executedProcess.getInputStream()).thenReturn(toInputStream(lsOutput)); assertThat(docker.listNetworks(), is(lsOutput)); verify(executor).execute("network", "ls"); }
@Value.Default public DockerExecutable dockerExecutable() { return DockerExecutable.builder() .dockerConfiguration(machine()) .build(); }
@Test public void call_docker_rm_with_force_flag_on_rm() throws IOException, InterruptedException { when(executedProcess.getInputStream()).thenReturn(toInputStream("")); docker.rm("testContainer"); verify(executor).execute("rm", "-f", "testContainer"); }
@Value.Default public DockerExecutable dockerExecutable() { return DockerExecutable.builder() .dockerConfiguration(machine()) .build(); }
@Override public Process execute(String... commands) throws IOException { List<String> args = ImmutableList.<String>builder() .add(dockerPath()) .add(commands) .build(); return dockerConfiguration().configuredDockerComposeProcess() .command(args) .redirectErrorStream(true) .start(); }
@Test public void call_docker_network_prune() throws IOException, InterruptedException { String lsOutput = "0.0.0.0:7000->7000/tcp"; when(executedProcess.getInputStream()).thenReturn(toInputStream(lsOutput)); assertThat(docker.pruneNetworks(), is(lsOutput)); verify(executor).execute("network", "prune", "--force"); }
@Value.Default public DockerExecutable dockerExecutable() { return DockerExecutable.builder() .dockerConfiguration(machine()) .build(); }
@Override public Process execute(String... commands) throws IOException { List<String> args = ImmutableList.<String>builder() .add(dockerPath()) .add(commands) .build(); return dockerConfiguration().configuredDockerComposeProcess() .command(args) .redirectErrorStream(true) .start(); }
@Before public void before() throws IOException { when(executor.execute(anyVararg())).thenReturn(executedProcess); when(executedProcess.exitValue()).thenReturn(0); }
private DockerExecutable dockerExecutable(ExtensionContext.Store store, Compose compose) { return getOrBuild(DockerExecutable.class, store, compose, () -> { DockerMachine machine = dockerMachine(store, compose); return DockerExecutable.builder() .dockerConfiguration(machine) .build(); }); }
public static Version version() throws IOException, InterruptedException { return new Docker(DockerExecutable.builder().dockerConfiguration(DockerMachine.localMachine().build()).build()) .configuredVersion(); }