/** * Parses a textual port specification (as used by the Docker CLI) to an {@link ExposedPort}. * * @param serialized * the specification, e.g. <code>80/tcp</code> * @return an {@link ExposedPort} matching the specification * @throws IllegalArgumentException * if the specification cannot be parsed */ public static ExposedPort parse(String serialized) throws IllegalArgumentException { try { String[] parts = serialized.split("/"); switch (parts.length) { case 1: return new ExposedPort(Integer.parseInt(parts[0])); case 2: return new ExposedPort(Integer.parseInt(parts[0]), InternetProtocol.parse(parts[1])); default: throw new IllegalArgumentException(); } } catch (Exception e) { throw new IllegalArgumentException("Error parsing ExposedPort '" + serialized + "'"); } }
/** * Parses a textual port specification (as used by the Docker CLI) to an {@link ExposedPort}. * * @param serialized * the specification, e.g. <code>80/tcp</code> * @return an {@link ExposedPort} matching the specification * @throws IllegalArgumentException * if the specification cannot be parsed */ public static ExposedPort parse(String serialized) throws IllegalArgumentException { try { String[] parts = serialized.split("/"); switch (parts.length) { case 1: return new ExposedPort(Integer.parseInt(parts[0])); case 2: return new ExposedPort(Integer.parseInt(parts[0]), InternetProtocol.parse(parts[1])); default: throw new IllegalArgumentException(); } } catch (Exception e) { throw new IllegalArgumentException("Error parsing ExposedPort '" + serialized + "'"); } }
private Set<ExposedPort> resolveExposedPorts(CubeContainer containerConfiguration, CreateContainerCmd createContainerCmd) { Set<ExposedPort> allExposedPorts = new HashSet<>(); if (containerConfiguration.getPortBindings() != null) { for (PortBinding binding : containerConfiguration.getPortBindings()) { allExposedPorts.add(new ExposedPort(binding.getExposedPort().getExposed(), InternetProtocol.parse(binding.getExposedPort().getType()))); } } if (containerConfiguration.getExposedPorts() != null) { for (org.arquillian.cube.docker.impl.client.config.ExposedPort port : containerConfiguration.getExposedPorts()) { allExposedPorts.add(new ExposedPort(port.getExposed(), InternetProtocol.parse(port.getType()))); } } return allExposedPorts; }
private Set<ExposedPort> resolveExposedPorts(CubeContainer containerConfiguration, CreateContainerCmd createContainerCmd) { Set<ExposedPort> allExposedPorts = new HashSet<>(); if (containerConfiguration.getPortBindings() != null) { for (PortBinding binding : containerConfiguration.getPortBindings()) { allExposedPorts.add(new ExposedPort(binding.getExposedPort().getExposed(), InternetProtocol.parse(binding.getExposedPort().getType()))); } } if (containerConfiguration.getExposedPorts() != null) { for (org.arquillian.cube.docker.impl.client.config.ExposedPort port : containerConfiguration.getExposedPorts()) { allExposedPorts.add(new ExposedPort(port.getExposed(), InternetProtocol.parse(port.getType()))); } } return allExposedPorts; }
private Ports toPortBindings(Collection<PortBinding> portBindings) { Ports ports = new Ports(); for (PortBinding portBinding : portBindings) { ports.bind( new ExposedPort( portBinding.getExposedPort().getExposed(), InternetProtocol.parse(portBinding.getExposedPort().getType())), new Binding(portBinding.getHost(), Integer.toString(portBinding.getBound()))); } return ports; }
private Ports toPortBindings(Collection<PortBinding> portBindings) { Ports ports = new Ports(); for (PortBinding portBinding : portBindings) { ports.bind( new ExposedPort( portBinding.getExposedPort().getExposed(), InternetProtocol.parse(portBinding.getExposedPort().getType())), new Binding(portBinding.getHost(), Integer.toString(portBinding.getBound()))); } return ports; }