private ImageConfiguration getImageWithContainerName(String containerName) { if (containerName == null) { return null; } List<ImageConfiguration> images = getImages().orElse(Collections.emptyList()); for (ImageConfiguration image : images) { String imageContainerName = KubernetesResourceUtil.extractContainerName(getContext().getGav(), image); if (Objects.equal(containerName, imageContainerName)) { return image; } } return null; }
private void mergeContainerName(ImageConfiguration imageConfiguration, Container container) { if (StringUtils.isBlank(container.getName())) { String containerName = extractContainerName(getContext().getGav(), imageConfiguration); log.verbose("Setting container name %s",containerName); container.setName(containerName); } }
List<Container> getContainers(ResourceConfig config, List<ImageConfiguration> images) { List<Container> ret = new ArrayList<>(); for (ImageConfiguration imageConfig : images) { if (imageConfig.getBuildConfiguration() != null) { Probe livenessProbe = probeHandler.getProbe(config.getLiveness()); Probe readinessProbe = probeHandler.getProbe(config.getReadiness()); Container container = new ContainerBuilder() .withName(KubernetesResourceUtil.extractContainerName(this.groupArtifactVersion, imageConfig)) .withImage(getImageName(imageConfig)) .withImagePullPolicy(getImagePullPolicy(config)) .withEnv(getEnvVars(config)) .withSecurityContext(createSecurityContext(config)) .withPorts(getContainerPorts(imageConfig)) .withVolumeMounts(getVolumeMounts(config)) .withLivenessProbe(livenessProbe) .withReadinessProbe(readinessProbe) .build(); ret.add(container); } } return ret; }