Skip to content

Commit

Permalink
Fix incorrect ImagePullPolicy forced setting
Browse files Browse the repository at this point in the history
When the container image group was being set to empty
(which is allowed as a result of
quarkusio#8139), then the
registry was incorrectly being determined as not being set

Fixes: quarkusio#11917
  • Loading branch information
geoand authored and gsmet committed Sep 8, 2020
1 parent eb9d977 commit 3655b80
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public static Optional<String> getActiveContainerImageCapability(Capabilities ca
if (activeContainerImageCapabilities.size() > 1) {
throw new IllegalStateException(String.join(" and ", activeContainerImageCapabilities)
+ " were detected, at most one container-image extension can be present.\n"
+ "Either remove the uneeded ones, or select one using the property 'quarkus.container-image-builder=<extension name (without the `container-image-` prefix)>'.");
+ "Either remove the unneeded ones, or select one using the property 'quarkus.container-image-builder=<extension name (without the `container-image-` prefix)>'.");
}
return activeContainerImageCapabilities.isEmpty() ? Optional.empty()
: Optional.of(activeContainerImageCapabilities.iterator().next());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,33 +35,6 @@ public static String getImage(Optional<String> registry, String repository, Stri
return sb.toString();
}

/*
* Checks if the specified image has a registry part.
*
* @param image the image
*
* @return true if registry is part of the image, false otherwise
*/
public static boolean hasRegistry(String image) {
String r = getRegistry(image);
return r != null && !r.isEmpty();
}

/**
* Return the registry part of the docker image.
*
* @param image The actual docker image.
* @return The registry or null, if not registry was found.
*/
public static String getRegistry(String image) {
String[] parts = image.split(SLASH);
if (parts.length <= 2) {
return null;
} else {
return parts[0];
}
}

/**
* Return the docker image repository.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package io.quarkus.kubernetes.deployment;

import static io.quarkus.container.image.deployment.util.ImageUtil.hasRegistry;

import java.util.Optional;

import io.quarkus.container.image.deployment.ContainerImageCapabilitiesUtil;
Expand All @@ -21,7 +19,7 @@ static boolean isRegistryMissingAndNotS2I(Capabilities capabilities, ContainerIm
return false;
}

return !hasRegistry(containerImageInfo.getImage())
&& !Capability.CONTAINER_IMAGE_S2I.equals(activeContainerImageCapability.get());
return !containerImageInfo.getRegistry().isPresent()
&& !Capability.CONTAINER_IMAGE_S2I.getName().equals(activeContainerImageCapability.get());
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@

package io.quarkus.kubernetes.deployment;

import static io.quarkus.container.image.deployment.util.ImageUtil.hasRegistry;
import static io.quarkus.kubernetes.deployment.Constants.KNATIVE;
import static io.quarkus.kubernetes.deployment.Constants.KUBERNETES;
import static io.quarkus.kubernetes.deployment.Constants.MINIKUBE;
Expand Down Expand Up @@ -150,7 +149,7 @@ private DeploymentTargetEntry determineDeploymentTarget(
checkForMissingRegistry = false;
}

if (checkForMissingRegistry && !hasRegistry(containerImageInfo.getImage())) {
if (checkForMissingRegistry && !containerImageInfo.getRegistry().isPresent()) {
log.warn(
"A Kubernetes deployment was requested, but the container image to be built will not be pushed to any registry"
+ " because \"quarkus.container-image.registry\" has not been set. The Kubernetes deployment will only work properly"
Expand Down

0 comments on commit 3655b80

Please sign in to comment.