use of io.fabric8.maven.docker.util.ImageName in project docker-maven-plugin by fabric8io.
the class DockerAccessWithHcClient method pushImage.
@Override
public void pushImage(String image, AuthConfig authConfig, String registry, int retries) throws DockerAccessException {
ImageName name = new ImageName(image);
String pushUrl = urlBuilder.pushImage(name, registry);
TemporaryImageHandler temporaryImageHandler = tagTemporaryImage(name, registry);
DockerAccessException dae = null;
try {
doPushImage(pushUrl, createAuthHeader(authConfig), createPullOrPushResponseHandler(), HTTP_OK, retries);
} catch (IOException e) {
dae = new DockerAccessException(e, "Unable to push '%s'%s", image, (registry != null) ? " to registry '" + registry + "'" : "");
throw dae;
} finally {
temporaryImageHandler.handle(dae);
}
}
use of io.fabric8.maven.docker.util.ImageName in project docker-maven-plugin by fabric8io.
the class LogsMojo method executeInternal.
@Override
protected void executeInternal(ServiceHub hub) throws MojoExecutionException, DockerAccessException {
QueryService queryService = hub.getQueryService();
LogDispatcher logDispatcher = getLogDispatcher(hub);
for (ImageConfiguration image : getResolvedImages()) {
String imageName = image.getName();
if (logAll) {
for (Container container : queryService.getContainersForImage(imageName, false)) {
doLogging(logDispatcher, image, container.getId());
}
} else {
Container container = queryService.getLatestContainerForImage(imageName, false);
if (container != null) {
doLogging(logDispatcher, image, container.getId());
}
}
}
if (follow) {
// Block forever ....
waitForEver();
}
}
use of io.fabric8.maven.docker.util.ImageName in project docker-maven-plugin by fabric8io.
the class RegistryServiceTest method givenAnImageConfiguration.
private void givenAnImageConfiguration(String imageName) {
final BuildImageConfiguration buildImageConfiguration = new BuildImageConfiguration.Builder().build();
imageConfiguration = new ImageConfiguration.Builder().name(imageName).buildConfig(buildImageConfiguration).build();
}
use of io.fabric8.maven.docker.util.ImageName in project docker-maven-plugin by fabric8io.
the class BuildService method tagImage.
public void tagImage(String imageName, String tag, String repo, CleanupMode cleanupMode) throws DockerAccessException {
if (tag != null) {
String fullImageName = new ImageName(imageName, tag).getNameWithOptionalRepository(repo);
String oldImageId = null;
if (cleanupMode.isRemove()) {
oldImageId = queryService.getImageId(fullImageName);
}
docker.tag(imageName, fullImageName, true);
log.info("Tagging image %s successful!", fullImageName);
String newImageId = queryService.getImageId(fullImageName);
removeDanglingImage(fullImageName, oldImageId, newImageId, cleanupMode, false);
}
}
use of io.fabric8.maven.docker.util.ImageName in project docker-maven-plugin by fabric8io.
the class JibBuildService method getRegistryCredentials.
static Credential getRegistryCredentials(RegistryService.RegistryConfig registryConfig, boolean isPush, ImageConfiguration imageConfiguration, Logger log) throws MojoExecutionException {
String registry;
if (isPush) {
registry = EnvUtil.firstRegistryOf(new ImageName(imageConfiguration.getName()).getRegistry(), imageConfiguration.getRegistry(), registryConfig.getRegistry());
} else {
registry = EnvUtil.firstRegistryOf(new ImageName(getBaseImage(imageConfiguration)).getRegistry(), registryConfig.getRegistry());
}
if (registry == null || DEFAULT_DOCKER_REGISTRIES.contains(registry)) {
// Let's assume docker is default registry.
registry = DOCKER_LOGIN_DEFAULT_REGISTRY;
}
AuthConfigFactory authConfigFactory = registryConfig.getAuthConfigFactory();
AuthConfig standardAuthConfig = authConfigFactory.createAuthConfig(isPush, registryConfig.isSkipExtendedAuth(), registryConfig.getAuthConfig(), registryConfig.getSettings(), null, registry);
Credential credentials = null;
if (standardAuthConfig != null) {
credentials = Credential.from(standardAuthConfig.getUsername(), standardAuthConfig.getPassword());
}
return credentials;
}
Aggregations