@Test public void shouldParseStoppedMachines() { when(executor.execCommandAsArray("docker-machine", "ls")).thenReturn(Arrays.asList( "NAME ACTIVE DRIVER STATE URL SWARM", "dev - virtualbox Stopped " )); DockerMachine dockerMachine = new DockerMachine(executor); final Set<Machine> list = dockerMachine.list(); assertThat(list, hasSize(1)); final Machine[] machines = list.toArray(new Machine[1]); assertThat(machines[0].getName(), is("dev")); assertThat(machines[0].getState(), is("Stopped")); assertThat(machines[0].getUrl(), is("")); }
public Set<Machine> list(String cliPathExec) { Set<Machine> machines = new HashSet<>(); List<String> output = commandLineExecutor.execCommandAsArray(createDockerMachineCommand(cliPathExec), "ls"); Map<String, Index> headerIndex = calculateStartingFieldsIndex(output.get(0)); for (String fields : output.subList(1, output.size())) { machines.add(parse(headerIndex, fields)); } return machines; }
DockerMachine extends AbstractCliInternetAddressResolver { public Set<Machine> list(String cliPathExec) { Set<Machine> machines = new HashSet<>(); List<String> output = commandLineExecutor.execCommandAsArray(createDockerMachineCommand(cliPathExec), "ls"); Map<String, Index> headerIndex = calculateStartingFieldsIndex(output.get(0)); for (String fields : output.subList(1, output.size())) { machines.add(parse(headerIndex, fields)); } return machines; } }
DockerMachine extends AbstractCliInternetAddressResolver { public Set<Machine> list(String cliPathExec) { Set<Machine> machines = new HashSet<>(); List<String> output = commandLineExecutor.execCommandAsArray(createDockerMachineCommand(cliPathExec), "ls"); Map<String, Index> headerIndex = calculateStartingFieldsIndex(output.get(0)); for (String fields : output.subList(1, output.size())) { machines.add(parse(headerIndex, fields)); } return machines; } DockerMachine(CommandLineExecutor commandLineExecutor); }
DockerMachine extends AbstractCliInternetAddressResolver { public Set<Machine> list(String cliPathExec) { Set<Machine> machines = new HashSet<>(); List<String> output = commandLineExecutor.execCommandAsArray(createDockerMachineCommand(cliPathExec), "ls"); Map<String, Index> headerIndex = calculateStartingFieldsIndex(output.get(0)); for (String fields : output.subList(1, output.size())) { machines.add(parse(headerIndex, fields)); } return machines; } DockerMachine(CommandLineExecutor commandLineExecutor); void setMachineName(String machineName); boolean isManuallyStarted(); void startDockerMachine(String cliPathExec, String machineName); void startDockerMachine(String machineName); void stopDockerMachine(String cliPathExec, String machineName); void stopDockerMachine(String machineName); boolean isDockerMachineInstalled(String cliPathExec); boolean isDockerMachineInstalled(); Set<Machine> list(String cliPathExec); Set<Machine> list(String cliPathExec, String field, String value); Set<Machine> list(); Set<Machine> list(String field, String value); void grantPermissionToDockerMachine(String machinePath); void createMachine(String machinePath, String machineDriver, String machineName); }
DockerMachine extends AbstractCliInternetAddressResolver { public Set<Machine> list(String cliPathExec) { Set<Machine> machines = new HashSet<>(); List<String> output = commandLineExecutor.execCommandAsArray(createDockerMachineCommand(cliPathExec), "ls"); Map<String, Index> headerIndex = calculateStartingFieldsIndex(output.get(0)); for (String fields : output.subList(1, output.size())) { machines.add(parse(headerIndex, fields)); } return machines; } DockerMachine(CommandLineExecutor commandLineExecutor); void setMachineName(String machineName); boolean isManuallyStarted(); void startDockerMachine(String cliPathExec, String machineName); void startDockerMachine(String machineName); void stopDockerMachine(String cliPathExec, String machineName); void stopDockerMachine(String machineName); boolean isDockerMachineInstalled(String cliPathExec); boolean isDockerMachineInstalled(); Set<Machine> list(String cliPathExec); Set<Machine> list(String cliPathExec, String field, String value); Set<Machine> list(); Set<Machine> list(String field, String value); void grantPermissionToDockerMachine(String machinePath); void createMachine(String machinePath, String machineDriver, String machineName); static final String DOCKER_MACHINE_EXEC; }