use of io.fabric8.maven.docker.util.ImageName in project docker-maven-plugin by fabric8io.
the class BuildService method tagImage.
public void tagImage(ImageConfiguration imageConfig) throws DockerAccessException {
List<String> tags = imageConfig.getBuildConfiguration().getTags();
if (!tags.isEmpty()) {
String imageName = imageConfig.getName();
log.info("%s: Tag with %s", imageConfig.getDescription(), EnvUtil.stringJoin(tags, ","));
BuildImageConfiguration buildConfig = imageConfig.getBuildConfiguration();
for (String tag : tags) {
tagImage(imageName, tag, null, buildConfig.cleanupMode());
}
}
}
use of io.fabric8.maven.docker.util.ImageName in project docker-maven-plugin by fabric8io.
the class RegistryService method pushImages.
/**
* Push a set of images to a registry
*
* @param imageConfigs images to push (but only if they have a build configuration)
* @param retries how often to retry
* @param registryConfig a global registry configuration
* @param skipTag flag to skip pushing tagged images
* @throws DockerAccessException
* @throws MojoExecutionException
*/
public void pushImages(Collection<ImageConfiguration> imageConfigs, int retries, RegistryConfig registryConfig, boolean skipTag) throws DockerAccessException, MojoExecutionException {
for (ImageConfiguration imageConfig : imageConfigs) {
BuildImageConfiguration buildConfig = imageConfig.getBuildConfiguration();
String name = imageConfig.getName();
if (buildConfig != null) {
if (buildConfig.skipPush()) {
log.info("%s : Skipped pushing", imageConfig.getDescription());
continue;
}
String configuredRegistry = EnvUtil.firstRegistryOf(new ImageName(imageConfig.getName()).getRegistry(), imageConfig.getRegistry(), registryConfig.getRegistry());
AuthConfig authConfig = createAuthConfig(true, new ImageName(name).getUser(), configuredRegistry, registryConfig);
long start = System.currentTimeMillis();
docker.pushImage(name, authConfig, configuredRegistry, retries);
log.info("Pushed %s in %s", name, EnvUtil.formatDurationTill(start));
if (!skipTag) {
for (String tag : imageConfig.getBuildConfiguration().getTags()) {
if (tag != null) {
docker.pushImage(new ImageName(name, tag).getFullName(), authConfig, configuredRegistry, retries);
}
}
}
}
}
}
use of io.fabric8.maven.docker.util.ImageName in project ballerina by ballerina-lang.
the class DefaultBallerinaDockerClient method getImage.
/**
* {@inheritDoc}
*/
@Override
public String getImage(String imageName, String dockerEnv) {
DockerClient client = getDockerClient(dockerEnv);
List<Image> images = client.image().list().filter(imageName).endImages();
// No images found?
if (images == null || images.size() < 1) {
return null;
}
for (Image image : images) {
// Invalid tags found?
if (image.getRepoTags() == null) {
continue;
}
String currentImageName = image.getRepoTags().get(0);
if (currentImageName.equals(imageName + ":" + Constants.IMAGE_VERSION_LATEST) || currentImageName.equals(imageName)) {
return currentImageName;
}
}
return null;
}
Aggregations