public class KubernetesResourceUtil extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
API_EXTENSIONS_VERSION |
static String |
API_VERSION |
| Constructor and Description |
|---|
KubernetesResourceUtil() |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
addPort(List<io.fabric8.kubernetes.api.model.ContainerPort> ports,
String portNumberText,
String portName,
io.fabric8.maven.docker.util.Logger log) |
static boolean |
checkForKind(io.fabric8.kubernetes.api.model.KubernetesListBuilder builder,
String... kinds) |
static String |
extractContainerName(org.apache.maven.project.MavenProject project,
io.fabric8.maven.docker.config.ImageConfiguration imageConfig) |
static <T> T |
findResourceByName(Iterable<io.fabric8.kubernetes.api.model.HasMetadata> entities,
Class<T> clazz,
String name)
Returns the resource of the given kind and name from the collection or null
|
static String |
getBuildStatusPhase(io.fabric8.openshift.api.model.Build build) |
static String |
getBuildStatusReason(io.fabric8.openshift.api.model.Build build) |
static Date |
getCreationTimestamp(io.fabric8.kubernetes.api.model.HasMetadata hasMetadata) |
static String |
getDockerContainerID(io.fabric8.kubernetes.api.model.Pod pod) |
static String |
getEnvVar(List<io.fabric8.kubernetes.api.model.EnvVar> envVarList,
String name,
String defaultValue) |
static String |
getNameWithSuffix(String name,
String kind) |
static io.fabric8.kubernetes.api.model.Pod |
getNewestPod(Collection<io.fabric8.kubernetes.api.model.Pod> pods) |
static io.fabric8.kubernetes.api.model.HasMetadata |
getResource(String defaultApiVersion,
String apiExtensionsVersion,
File file,
String appName)
Read a Kubernetes resource fragment and add meta information extracted from the filename
to the resource descriptor.
|
static void |
handleKubernetesClientException(io.fabric8.kubernetes.client.KubernetesClientException e,
io.fabric8.maven.docker.util.Logger logger) |
static boolean |
isNewerResource(io.fabric8.kubernetes.api.model.HasMetadata newer,
io.fabric8.kubernetes.api.model.HasMetadata older) |
static File[] |
listResourceFragments(File resourceDir) |
static boolean |
podHasContainerImage(io.fabric8.kubernetes.api.model.Pod pod,
String imageName) |
static io.fabric8.kubernetes.api.model.KubernetesListBuilder |
readResourceFragmentsFrom(String apiVersion,
String apiExtensionsVersion,
String defaultName,
File[] resourceFiles)
Read all Kubernetes resource fragments from a directory and create a
KubernetesListBuilder which
can be adapted later. |
static Map<String,String> |
removeVersionSelector(Map<String,String> selector) |
static boolean |
setEnvVar(List<io.fabric8.kubernetes.api.model.EnvVar> envVarList,
String name,
String value) |
static String |
toJson(Object resource) |
static String |
toYaml(Object resource) |
static void |
validateKubernetesMasterUrl(URL masterUrl) |
static void |
watchLogInThread(io.fabric8.kubernetes.client.dsl.LogWatch logWatcher,
String failureMessage,
CountDownLatch terminateLatch,
io.fabric8.maven.docker.util.Logger log) |
static File |
writeResource(Object resource,
File target,
ResourceFileType resourceFileType) |
static File |
writeResourceFile(Object resource,
File outputFile,
ResourceFileType resourceFileType) |
public static final String API_VERSION
public static final String API_EXTENSIONS_VERSION
public static io.fabric8.kubernetes.api.model.KubernetesListBuilder readResourceFragmentsFrom(String apiVersion, String apiExtensionsVersion, String defaultName, File[] resourceFiles) throws IOException
KubernetesListBuilder which
can be adapted later.apiVersion - the api version to useapiExtensionsVersion - the extension version to usedefaultName - the default name to use when none is givenappResourcesOnly - if only resource with the defaultName should be returned ?resourceFiles - files to add.IOExceptionpublic static io.fabric8.kubernetes.api.model.HasMetadata getResource(String defaultApiVersion, String apiExtensionsVersion, File file, String appName) throws IOException
defaultApiVersion - the API version to add if not given.apiExtensionsVersion - the API version for extensionsfile - file to read, whose name must match FILENAME_PATTERN. @return map holding the fragmentappName - resource name specifying resources belonging to this applicationIOExceptionpublic static String toYaml(Object resource) throws com.fasterxml.jackson.core.JsonProcessingException
com.fasterxml.jackson.core.JsonProcessingExceptionpublic static String toJson(Object resource) throws com.fasterxml.jackson.core.JsonProcessingException
com.fasterxml.jackson.core.JsonProcessingExceptionpublic static File writeResource(Object resource, File target, ResourceFileType resourceFileType) throws IOException
IOExceptionpublic static File writeResourceFile(Object resource, File outputFile, ResourceFileType resourceFileType) throws IOException
IOExceptionpublic static String extractContainerName(org.apache.maven.project.MavenProject project, io.fabric8.maven.docker.config.ImageConfiguration imageConfig)
public static Map<String,String> removeVersionSelector(Map<String,String> selector)
public static boolean checkForKind(io.fabric8.kubernetes.api.model.KubernetesListBuilder builder,
String... kinds)
public static boolean addPort(List<io.fabric8.kubernetes.api.model.ContainerPort> ports, String portNumberText, String portName, io.fabric8.maven.docker.util.Logger log)
public static boolean setEnvVar(List<io.fabric8.kubernetes.api.model.EnvVar> envVarList, String name, String value)
public static String getEnvVar(List<io.fabric8.kubernetes.api.model.EnvVar> envVarList, String name, String defaultValue)
public static void validateKubernetesMasterUrl(URL masterUrl) throws org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoExecutionExceptionpublic static void handleKubernetesClientException(io.fabric8.kubernetes.client.KubernetesClientException e,
io.fabric8.maven.docker.util.Logger logger)
throws org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoExecutionExceptionpublic static <T> T findResourceByName(Iterable<io.fabric8.kubernetes.api.model.HasMetadata> entities, Class<T> clazz, String name)
public static String getBuildStatusPhase(io.fabric8.openshift.api.model.Build build)
public static String getBuildStatusReason(io.fabric8.openshift.api.model.Build build)
public static void watchLogInThread(io.fabric8.kubernetes.client.dsl.LogWatch logWatcher,
String failureMessage,
CountDownLatch terminateLatch,
io.fabric8.maven.docker.util.Logger log)
public static io.fabric8.kubernetes.api.model.Pod getNewestPod(Collection<io.fabric8.kubernetes.api.model.Pod> pods)
public static Date getCreationTimestamp(io.fabric8.kubernetes.api.model.HasMetadata hasMetadata)
public static boolean podHasContainerImage(io.fabric8.kubernetes.api.model.Pod pod,
String imageName)
public static String getDockerContainerID(io.fabric8.kubernetes.api.model.Pod pod)
public static boolean isNewerResource(io.fabric8.kubernetes.api.model.HasMetadata newer,
io.fabric8.kubernetes.api.model.HasMetadata older)
Copyright © 2016. All rights reserved.