use of org.eclipse.jkube.kit.config.image.ImageName in project jkube by eclipse.
the class BaseGenerator method addFrom.
/**
* Add the base image either from configuration or from a given selector
*
* @param builder for the build image configuration to add the from to.
*/
protected void addFrom(BuildConfiguration.BuildConfigurationBuilder builder) {
String fromMode = getConfigWithFallback(Config.FROM_MODE, "jkube.generator.fromMode", "docker");
String from = getFromAsConfigured();
if ("docker".equalsIgnoreCase(fromMode)) {
String fromImage = from;
if (fromImage == null) {
fromImage = fromSelector != null ? fromSelector.getFrom() : null;
}
builder.from(fromImage);
log.info("Using Docker image %s as base / builder", fromImage);
} else if ("istag".equalsIgnoreCase(fromMode)) {
Map<String, String> fromExt = new HashMap<>();
if (from != null) {
ImageName iName = new ImageName(from);
// user/project is considered to be the namespace
String tag = iName.getTag();
if (StringUtils.isBlank(tag)) {
tag = "latest";
}
fromExt.put(JKubeBuildStrategy.SourceStrategy.name.key(), iName.getSimpleName() + ":" + tag);
if (iName.getUser() != null) {
fromExt.put(JKubeBuildStrategy.SourceStrategy.namespace.key(), iName.getUser());
}
fromExt.put(JKubeBuildStrategy.SourceStrategy.kind.key(), "ImageStreamTag");
} else {
fromExt = fromSelector != null ? fromSelector.getImageStreamTagFromExt() : null;
}
if (fromExt != null) {
String namespace = fromExt.get(JKubeBuildStrategy.SourceStrategy.namespace.key());
if (namespace != null) {
log.info("Using ImageStreamTag '%s' from namespace '%s' as builder image", fromExt.get(JKubeBuildStrategy.SourceStrategy.name.key()), namespace);
} else {
log.info("Using ImageStreamTag '%s' as builder image", fromExt.get(JKubeBuildStrategy.SourceStrategy.name.key()));
}
builder.fromExt(fromExt);
}
} else {
throw new IllegalArgumentException(String.format("Invalid 'fromMode' in generator configuration for '%s'", getName()));
}
}
use of org.eclipse.jkube.kit.config.image.ImageName in project jkube by eclipse.
the class JibServiceUtil method getAllImageTags.
static Set<String> getAllImageTags(List<String> tags, String imageName) {
ImageName tempImage = new ImageName(imageName);
Set<String> tagSet = tags.stream().filter(Objects::nonNull).collect(Collectors.toSet());
if (!tempImage.getTag().isEmpty()) {
tagSet.add(tempImage.getTag());
}
return tagSet;
}
Aggregations