private Pod getNewestPod(List<Pod> items) { Pod targetPod = null; if (items != null) { for (Pod pod : items) { if (KubernetesHelper.isPodWaiting(pod) || KubernetesHelper.isPodRunning(pod)) { if (targetPod == null || (KubernetesHelper.isPodReady(pod) && KubernetesResourceUtil.isNewerResource(pod, targetPod))) { targetPod = pod; } } } } return targetPod; }
protected final static void initializeKindFilenameMapper() { final Map<String, List<String>> mappings = KindFilenameMapperUtil.loadMappings(); updateKindFilenameMapper(mappings); }
public static String getPodStatusDescription(Pod pod) { return KubernetesHelper.getPodPhase(pod) + " " + getPodCondition(pod); }
@Override public String toString() { return value(); } }
public static boolean isFinished(String status) { return isCompleted(status) || isFailed(status) || isCancelled(status); }
@Override public void visit(PodSpecBuilder builder) { KubernetesResourceUtil.mergePodSpec(builder, podSpec, name); } });
/** * Returns the service host name or a blank string if it could not be resolved */ private static String serviceToHostOrBlank(String serviceName) { return getEnvVarOrSystemProperty(toServiceHostEnvironmentVariable(serviceName), ""); }
@Override protected void applyEntities(KubernetesClient kubernetes, String namespace, String fileName, Set<HasMetadata> entities) throws Exception { deleteEntities(kubernetes, namespace, entities, s2iBuildNameSuffix, log); } }
/** * Returns the named port for the given service name or blank */ private static String serviceToPortOrBlank(String serviceName) { String envVarName = toServicePortEnvironmentVariable(serviceName); return getEnvVarOrSystemProperty(envVarName, ""); }
public static boolean isOpenShiftClient(KubernetesClient kubernetes) { return asOpenShiftClient(kubernetes) != null; } }
private static String serviceToProtocol(String serviceName, String servicePort) { return getEnvVarOrSystemProperty(toEnvVariable(serviceName + PORT_SUFFIX + "_" + servicePort + PROTO_SUFFIX), DEFAULT_PROTO); }
/** * Returns true if the pod is running */ public static boolean isPodRunning(Pod pod) { return isInPodPhase(pod, "run"); }
/** * Returns the kubernetes environment variable name for the service host for the given service name */ private static String toServiceHostEnvironmentVariable(String serviceName) { return toEnvVariable(serviceName + HOST_SUFFIX); }
static <L, R> boolean itemExists(L item, Collection<R> collection) { for (R candidate : collection) { if (configEqual(item, candidate)) { return true; } } return false; }
static <L, R> boolean subCollection(Collection<L> left, Collection<R> right) { for (L candidate : left) { if (!itemExists(candidate, right)) { return false; } } return true; }
private static String getEnvVarOrSystemProperty(String envVarName, String defaultValue) { return getEnvVarOrSystemProperty(envVarName,envVarName,defaultValue); } }
@Override public void visit(PodSpecBuilder builder) { KubernetesResourceUtil.mergePodSpec(builder, podSpec, name); } });
public static boolean isPodWaiting(Pod pod) { return isInPodPhase(pod, "wait"); }
private static String toServicePortEnvironmentVariable(String serviceName) { String name = serviceName + PORT_SUFFIX; return toEnvVariable(name); }