use of com.github.dockerjava.api.model.AuthConfig in project camel by apache.
the class AsyncDockerProducer method executePullImageRequest.
/**
* Produces a pull image request
*
* @param client
* @param message
* @return
*/
private PullImageCmd executePullImageRequest(DockerClient client, Message message) {
LOGGER.debug("Executing Docker Pull Image Request");
String repository = DockerHelper.getProperty(DockerConstants.DOCKER_REPOSITORY, configuration, message, String.class);
ObjectHelper.notNull(repository, "Repository must be specified");
PullImageCmd pullImageCmd = client.pullImageCmd(repository);
String registry = DockerHelper.getProperty(DockerConstants.DOCKER_REGISTRY, configuration, message, String.class);
if (registry != null) {
pullImageCmd.withRegistry(registry);
}
String tag = DockerHelper.getProperty(DockerConstants.DOCKER_TAG, configuration, message, String.class);
if (tag != null) {
pullImageCmd.withTag(tag);
}
AuthConfig authConfig = client.authConfig();
if (authConfig != null) {
pullImageCmd.withAuthConfig(authConfig);
}
return pullImageCmd;
}
use of com.github.dockerjava.api.model.AuthConfig in project camel by apache.
the class DockerProducer method executeAuthRequest.
/*********************
* General Requests
********************/
/**
* Produces a Authorization request
*
* @param client
* @param message
* @return
*/
private AuthCmd executeAuthRequest(DockerClient client, Message message) {
LOGGER.debug("Executing Docker Auth Request");
AuthCmd authCmd = client.authCmd();
AuthConfig authConfig = client.authConfig();
if (authCmd != null) {
authCmd.withAuthConfig(authConfig);
}
return authCmd;
}
use of com.github.dockerjava.api.model.AuthConfig in project camel by apache.
the class AsyncDockerProducer method executePushImageRequest.
/**
* Produces a push image request
*
* @param client
* @param message
* @return
*/
private PushImageCmd executePushImageRequest(DockerClient client, Message message) {
LOGGER.debug("Executing Docker Push Image Request");
String name = DockerHelper.getProperty(DockerConstants.DOCKER_NAME, configuration, message, String.class);
ObjectHelper.notNull(name, "Image name must be specified");
PushImageCmd pushImageCmd = client.pushImageCmd(name);
String tag = DockerHelper.getProperty(DockerConstants.DOCKER_TAG, configuration, message, String.class);
if (tag != null) {
pushImageCmd.withTag(tag);
}
AuthConfig authConfig = client.authConfig();
if (authConfig != null) {
pushImageCmd.withAuthConfig(authConfig);
}
return pushImageCmd;
}
use of com.github.dockerjava.api.model.AuthConfig in project vespa by vespa-engine.
the class DockerImpl method pullImageAsyncIfNeeded.
@Override
public boolean pullImageAsyncIfNeeded(final DockerImage image) {
try {
synchronized (monitor) {
if (scheduledPulls.contains(image))
return true;
if (imageIsDownloaded(image))
return false;
scheduledPulls.add(image);
PullImageCmd pullImageCmd = dockerClient.pullImageCmd(image.asString());
dockerRegistryCredentialsSupplier.flatMap(credentialsSupplier -> credentialsSupplier.getCredentials(image)).map(credentials -> new AuthConfig().withRegistryAddress(credentials.registry.toString()).withUsername(credentials.username).withPassword(credentials.password)).ifPresent(pullImageCmd::withAuthConfig);
logger.log(LogLevel.INFO, "Starting download of " + image.asString());
pullImageCmd.exec(new ImagePullCallback(image));
return true;
}
} catch (RuntimeException e) {
numberOfDockerDaemonFails.add();
throw new DockerException("Failed to pull image '" + image.asString() + "'", e);
}
}
Aggregations