use of io.quarkus.container.spi.ContainerImageLabelBuildItem in project quarkus by quarkusio.
the class JibProcessor method createContainerBuilderFromLegacyJar.
private JibContainerBuilder createContainerBuilderFromLegacyJar(String baseJvmImage, JibConfig jibConfig, ContainerImageConfig containerImageConfig, JarBuildItem sourceJarBuildItem, OutputTargetBuildItem outputTargetBuildItem, MainClassBuildItem mainClassBuildItem, List<ContainerImageLabelBuildItem> containerImageLabels) {
try {
// not ideal since this has been previously zipped - we would like to just reuse it
Path classesDir = outputTargetBuildItem.getOutputDirectory().resolve("jib");
ZipUtils.unzip(sourceJarBuildItem.getPath(), classesDir);
JavaContainerBuilder javaContainerBuilder = JavaContainerBuilder.from(toRegistryImage(ImageReference.parse(baseJvmImage), jibConfig.baseRegistryUsername, jibConfig.baseRegistryPassword)).addResources(classesDir, IS_CLASS_PREDICATE.negate()).addClasses(classesDir, IS_CLASS_PREDICATE);
// when there is no custom entry point, we just set everything up for a regular java run
if (!jibConfig.jvmEntrypoint.isPresent()) {
javaContainerBuilder.addJvmFlags(determineEffectiveJvmArguments(jibConfig, Optional.empty())).setMainClass(mainClassBuildItem.getClassName());
}
if (sourceJarBuildItem.getLibraryDir() != null) {
try (Stream<Path> dependenciesPaths = Files.list(sourceJarBuildItem.getLibraryDir())) {
javaContainerBuilder.addDependencies(dependenciesPaths.filter(p -> Files.isRegularFile(p) && p.getFileName().toString().endsWith(".jar")).sorted(Comparator.comparing(Path::getFileName)).collect(Collectors.toList()));
}
}
JibContainerBuilder jibContainerBuilder = javaContainerBuilder.toContainerBuilder().setEnvironment(getEnvironmentVariables(jibConfig)).setLabels(allLabels(jibConfig, containerImageConfig, containerImageLabels));
if (jibConfig.useCurrentTimestamp) {
jibContainerBuilder.setCreationTime(Instant.now());
}
if (jibConfig.jvmEntrypoint.isPresent()) {
jibContainerBuilder.setEntrypoint(jibConfig.jvmEntrypoint.get());
}
return jibContainerBuilder;
} catch (IOException e) {
throw new UncheckedIOException(e);
} catch (InvalidImageReferenceException e) {
throw new RuntimeException(e);
}
}
use of io.quarkus.container.spi.ContainerImageLabelBuildItem in project quarkus by quarkusio.
the class VanillaKubernetesProcessor method createLabels.
@BuildStep
public void createLabels(KubernetesConfig config, BuildProducer<KubernetesLabelBuildItem> labels, BuildProducer<ContainerImageLabelBuildItem> imageLabels) {
config.labels.forEach((k, v) -> {
labels.produce(new KubernetesLabelBuildItem(k, v, KUBERNETES));
imageLabels.produce(new ContainerImageLabelBuildItem(k, v));
});
}
use of io.quarkus.container.spi.ContainerImageLabelBuildItem in project quarkus by quarkusio.
the class JibProcessor method allLabels.
private Map<String, String> allLabels(JibConfig jibConfig, ContainerImageConfig containerImageConfig, List<ContainerImageLabelBuildItem> containerImageLabels) {
if (jibConfig.labels.isEmpty() && containerImageLabels.isEmpty() && containerImageConfig.labels.isEmpty()) {
return Collections.emptyMap();
}
final Map<String, String> allLabels = new HashMap<>(jibConfig.labels);
allLabels.putAll(containerImageConfig.labels);
for (ContainerImageLabelBuildItem containerImageLabel : containerImageLabels) {
// we want the user supplied labels to take precedence so the user can override labels generated from other extensions if desired
allLabels.putIfAbsent(containerImageLabel.getName(), containerImageLabel.getValue());
}
return allLabels;
}
use of io.quarkus.container.spi.ContainerImageLabelBuildItem in project quarkus by quarkusio.
the class KindProcessor method createLabels.
@BuildStep
public void createLabels(KubernetesConfig config, BuildProducer<KubernetesLabelBuildItem> labels, BuildProducer<ContainerImageLabelBuildItem> imageLabels) {
config.getLabels().forEach((k, v) -> {
labels.produce(new KubernetesLabelBuildItem(k, v, KIND));
imageLabels.produce(new ContainerImageLabelBuildItem(k, v));
});
}
use of io.quarkus.container.spi.ContainerImageLabelBuildItem in project quarkus by quarkusio.
the class MinikubeProcessor method createLabels.
@BuildStep
public void createLabels(KubernetesConfig config, BuildProducer<KubernetesLabelBuildItem> labels, BuildProducer<ContainerImageLabelBuildItem> imageLabels) {
config.getLabels().forEach((k, v) -> {
labels.produce(new KubernetesLabelBuildItem(k, v, MINIKUBE));
imageLabels.produce(new ContainerImageLabelBuildItem(k, v));
});
}
Aggregations