use of io.fabric8.maven.docker.util.ImageNameFormatter in project fabric8-maven-plugin by fabric8io.
the class ResourceMojo method getResolvedImages.
private List<ImageConfiguration> getResolvedImages(List<ImageConfiguration> images, final Logger log) throws MojoExecutionException {
List<ImageConfiguration> ret;
ret = ConfigHelper.resolveImages(log, images, new ConfigHelper.Resolver() {
@Override
public List<ImageConfiguration> resolve(ImageConfiguration image) {
return imageConfigResolver.resolve(image, project, session);
}
}, // no filter on image name yet (TODO: Maybe add this, too ?)
null, new ConfigHelper.Customizer() {
@Override
public List<ImageConfiguration> customizeConfig(List<ImageConfiguration> configs) {
try {
GeneratorContext ctx = new GeneratorContext.Builder().config(extractGeneratorConfig()).project(project).session(session).goalFinder(goalFinder).goalName("fabric8:resource").logger(log).mode(mode).strategy(buildStrategy).useProjectClasspath(useProjectClasspath).build();
return GeneratorManager.generate(configs, ctx, true);
} catch (Exception e) {
throw new IllegalArgumentException("Cannot extract generator: " + e, e);
}
}
});
Date now = getBuildReferenceDate();
storeReferenceDateInPluginContext(now);
String minimalApiVersion = ConfigHelper.initAndValidate(ret, null, /* no minimal api version */
new ImageNameFormatter(project, now), log);
return ret;
}
use of io.fabric8.maven.docker.util.ImageNameFormatter in project fabric8-maven-plugin by fabric8io.
the class DockerImageWatcher method buildImage.
protected void buildImage(ImageConfiguration imageConfig) throws DockerAccessException, MojoExecutionException {
String imageName = imageConfig.getName();
// lets regenerate the label
try {
String imagePrefix = getImagePrefix(imageName);
imageName = imagePrefix + "%t";
ImageNameFormatter formatter = new ImageNameFormatter(getContext().getProject(), new Date());
imageName = formatter.format(imageName);
imageConfig.setName(imageName);
log.info("New image name: " + imageConfig.getName());
} catch (Exception e) {
log.error("Caught: " + e, e);
}
}
use of io.fabric8.maven.docker.util.ImageNameFormatter in project docker-maven-plugin by fabric8io.
the class AbstractDockerMojo method initImageConfiguration.
// Resolve and customize image configuration
private String initImageConfiguration(Date buildTimeStamp) {
// Resolve images
resolvedImages = ConfigHelper.resolveImages(log, // Unresolved images
getAllImages(), new ConfigHelper.Resolver() {
@Override
public List<ImageConfiguration> resolve(ImageConfiguration image) {
return imageConfigResolver.resolve(image, project, session);
}
}, // A filter which image to process
filter, // customizer (can be overwritten by a subclass)
this);
// Check for simple Dockerfile mode
File topDockerfile = new File(project.getBasedir(), "Dockerfile");
if (topDockerfile.exists()) {
if (resolvedImages.isEmpty()) {
resolvedImages.add(createSimpleDockerfileConfig(topDockerfile));
} else if (resolvedImages.size() == 1 && resolvedImages.get(0).getBuildConfiguration() == null) {
resolvedImages.set(0, addSimpleDockerfileConfig(resolvedImages.get(0), topDockerfile));
}
}
// Initialize configuration and detect minimal API version
return ConfigHelper.initAndValidate(resolvedImages, apiVersion, new ImageNameFormatter(project, buildTimeStamp), log);
}
Aggregations