use of com.spotify.docker.client.auth.FixedRegistryAuthSupplier in project TOSCAna by StuPro-TOSCAna.
the class PushingImageBuilder method getDockerClient.
@Override
protected DockerClient getDockerClient() throws DockerCertificateException {
// Initialize Docker Client
logger.debug("Attempting to get connection to the Docker Daemon");
RegistryAuth auth = this.credentials.toRegistryAuth();
return DefaultDockerClient.fromEnv().registryAuthSupplier(new FixedRegistryAuthSupplier(auth, RegistryConfigs.create(Collections.singletonMap(this.credentials.getRegistryURL(), auth)))).build();
}
use of com.spotify.docker.client.auth.FixedRegistryAuthSupplier in project TOSCAna by StuPro-TOSCAna.
the class PushingImageBuilderIT method validate.
@Override
public void validate(String tag) throws Exception {
RegistryAuth auth = credentials.toRegistryAuth();
DockerClient client = DefaultDockerClient.fromEnv().registryAuthSupplier(new FixedRegistryAuthSupplier(auth, RegistryConfigs.create(Collections.singletonMap(credentials.getRegistryURL(), auth)))).build();
client.removeImage(tag);
// Pull the image from the registry
client.pull(tag);
}
use of com.spotify.docker.client.auth.FixedRegistryAuthSupplier in project docker-client by spotify.
the class DefaultDockerClientTest method testBuildImageIdWithAuth.
@Test
public void testBuildImageIdWithAuth() throws Exception {
final Path dockerDirectory = getResource("dockerDirectory");
final AtomicReference<String> imageIdFromMessage = new AtomicReference<>();
final RegistryAuth registryAuth = RegistryAuth.builder().username(AUTH_USERNAME).password(AUTH_PASSWORD).build();
final DockerClient sut2 = DefaultDockerClient.fromEnv().registryAuthSupplier(new FixedRegistryAuthSupplier(registryAuth, RegistryConfigs.create(singletonMap("", registryAuth)))).build();
final String returnedImageId = sut2.build(dockerDirectory, "test", new ProgressHandler() {
@Override
public void progress(ProgressMessage message) throws DockerException {
final String imageId = message.buildImageId();
if (imageId != null) {
imageIdFromMessage.set(imageId);
}
}
});
assertThat(returnedImageId, is(imageIdFromMessage.get()));
}
use of com.spotify.docker.client.auth.FixedRegistryAuthSupplier in project docker-client by spotify.
the class PushPullIT method setup.
@Before
public void setup() throws Exception {
final RegistryAuth registryAuth = RegistryAuth.builder().username(LOCAL_AUTH_USERNAME).password(LOCAL_AUTH_PASSWORD).build();
client = DefaultDockerClient.fromEnv().registryAuthSupplier(new FixedRegistryAuthSupplier(registryAuth, RegistryConfigs.create(singletonMap(HUB_NAME, registryAuth)))).build();
System.out.printf("- %s\n", testName.getMethodName());
}
use of com.spotify.docker.client.auth.FixedRegistryAuthSupplier in project docker-client by spotify.
the class PushPullIT method testPushHubPrivateImageWithAuth.
@Test
public void testPushHubPrivateImageWithAuth() throws Exception {
// Push an image to a private repo on Docker Hub and check it succeeds
final String dockerDirectory = Resources.getResource("dockerDirectory").getPath();
final RegistryAuth registryAuth = RegistryAuth.builder().username(HUB_AUTH_USERNAME).password(HUB_AUTH_PASSWORD).build();
final DockerClient client = DefaultDockerClient.fromEnv().registryAuthSupplier(new FixedRegistryAuthSupplier(registryAuth, RegistryConfigs.create(singletonMap(HUB_NAME, registryAuth)))).build();
client.build(Paths.get(dockerDirectory), HUB_PRIVATE_IMAGE);
client.push(HUB_PRIVATE_IMAGE);
}
Aggregations