/** * Adds a file system binding. Consider using {@link #withFileSystemBind(String, String, BindMode)} * for building a container in a fluent style. * * @param hostPath the file system path on the host * @param containerPath the file system path inside the container * @param mode the bind mode */ default void addFileSystemBind(final String hostPath, final String containerPath, final BindMode mode) { addFileSystemBind(hostPath, containerPath, mode, SelinuxContext.NONE); }
/** * Add an environment variable to be passed to the container. * * @param key environment variable key * @param mapper environment variable value mapper, accepts old value as an argument * @return this */ default SELF withEnv(String key, Function<Optional<String>, String> mapper) { Optional<String> oldValue = Optional.ofNullable(getEnvMap().get(key)); return withEnv(key, mapper.apply(oldValue)); }
/** * Map a resource (file or directory) on the classpath to a path inside the container. * This will only work if you are running your tests outside a Docker container. * * @param resourcePath path to the resource on the classpath (relative to the classpath root; should not start with a leading slash) * @param containerPath path this should be mapped to inside the container * @param mode access mode for the file * @return this */ default SELF withClasspathResourceMapping(final String resourcePath, final String containerPath, final BindMode mode) { withClasspathResourceMapping(resourcePath, containerPath, mode, SelinuxContext.NONE); return self(); }
/** * Follow container output, sending each frame (usually, line) to a consumer. This method allows Stdout and/or stderr * to be selected. * * @param consumer consumer that the frames should be sent to * @param types types that should be followed (one or both of STDOUT, STDERR) */ default void followOutput(Consumer<OutputFrame> consumer, OutputFrame.OutputType... types) { LogUtils.followOutput(DockerClientFactory.instance().client(), getContainerId(), consumer, types); }
/** * Adds a file system binding. * * @param hostPath the file system path on the host * @param containerPath the file system path inside the container * @return this */ default SELF withFileSystemBind(String hostPath, String containerPath) { return withFileSystemBind(hostPath, containerPath, BindMode.READ_WRITE); }
private void addVolumesFrom(Container container, BindMode mode) { volumesFroms.add(new VolumesFrom(container.getContainerName(), mode.accessMode)); }
/** * Follow container output, sending each frame (usually, line) to a consumer. Stdout and stderr will be followed. * * @param consumer consumer that the frames should be sent to */ default void followOutput(Consumer<OutputFrame> consumer) { LogUtils.followOutput(DockerClientFactory.instance().client(), getContainerId(), consumer); }
/** * Adds a file system binding. * * @param hostPath the file system path on the host * @param containerPath the file system path inside the container * @return this */ default SELF withFileSystemBind(String hostPath, String containerPath) { return withFileSystemBind(hostPath, containerPath, BindMode.READ_WRITE); }
/** * Add an environment variable to be passed to the container. * * @param key environment variable key * @param mapper environment variable value mapper, accepts old value as an argument * @return this */ default SELF withEnv(String key, Function<Optional<String>, String> mapper) { Optional<String> oldValue = Optional.ofNullable(getEnvMap().get(key)); return withEnv(key, mapper.apply(oldValue)); }
/** * Map a resource (file or directory) on the classpath to a path inside the container. * This will only work if you are running your tests outside a Docker container. * * @param resourcePath path to the resource on the classpath (relative to the classpath root; should not start with a leading slash) * @param containerPath path this should be mapped to inside the container * @param mode access mode for the file * @return this */ default SELF withClasspathResourceMapping(final String resourcePath, final String containerPath, final BindMode mode) { withClasspathResourceMapping(resourcePath, containerPath, mode, SelinuxContext.NONE); return self(); }
/** * Follow container output, sending each frame (usually, line) to a consumer. This method allows Stdout and/or stderr * to be selected. * * @param consumer consumer that the frames should be sent to * @param types types that should be followed (one or both of STDOUT, STDERR) */ default void followOutput(Consumer<OutputFrame> consumer, OutputFrame.OutputType... types) { LogUtils.followOutput(DockerClientFactory.instance().client(), getContainerId(), consumer, types); }
/** * Adds a file system binding. Consider using {@link #withFileSystemBind(String, String, BindMode)} * for building a container in a fluent style. * * @param hostPath the file system path on the host * @param containerPath the file system path inside the container * @param mode the bind mode */ default void addFileSystemBind(final String hostPath, final String containerPath, final BindMode mode) { addFileSystemBind(hostPath, containerPath, mode, SelinuxContext.NONE); }
/** * Follow container output, sending each frame (usually, line) to a consumer. Stdout and stderr will be followed. * * @param consumer consumer that the frames should be sent to */ default void followOutput(Consumer<OutputFrame> consumer) { LogUtils.followOutput(DockerClientFactory.instance().client(), getContainerId(), consumer); }