public class OpenShiftUtils extends Object
| Constructor and Description |
|---|
OpenShiftUtils() |
| Modifier and Type | Method and Description |
|---|---|
static NamespaceName |
buildConfigNameFromJenkinsJobName(String jobName,
String defaultNamespace)
Maps a Jenkins Job name to an ObjectShift BuildConfig name
|
static void |
cancelOpenShiftBuild(io.fabric8.openshift.api.model.Build build) |
static String |
dumpWithoutRuntimeStateAsYaml(io.fabric8.kubernetes.api.model.HasMetadata obj) |
static String |
formatTimestamp(long timestamp) |
static String |
getExternalServiceUrl(io.fabric8.openshift.client.OpenShiftClient openShiftClient,
String protocolText,
String namespace,
String serviceName)
Returns the public URL of the given service
|
static String |
getJenkinsURL(io.fabric8.openshift.client.OpenShiftClient openShiftClient,
String namespace)
Calculates the external URL to access Jenkins
|
static String |
getNamespaceOrUseDefault(String configuredNamespace,
io.fabric8.openshift.client.OpenShiftClient client)
Gets the current namespace running Jenkins inside or returns a reasonable default
|
static io.fabric8.openshift.client.OpenShiftClient |
getOpenShiftClient() |
static void |
initializeOpenShiftClient(String serverUrl)
Initializes an
OpenShiftClient |
static boolean |
isJenkinsBuildConfig(io.fabric8.openshift.api.model.BuildConfig bc)
Checks if a
BuildConfig relates to a Jenkins build |
static boolean |
isResourceWithoutStateEqual(io.fabric8.kubernetes.api.model.HasMetadata oldObj,
io.fabric8.kubernetes.api.model.HasMetadata newObj) |
static String |
jenkinsJobName(io.fabric8.openshift.api.model.BuildConfig bc,
String defaultNamespace)
Finds the Jenkins job for the given
BuildConfig and defaultNamespace |
static String |
jenkinsJobName(String namespace,
String buildConfigName,
String defaultNamespace)
Creates the Jenkins Job name for the given buildConfigName in a namespace and the default namespace for jenkins
|
static long |
parseResourceVersion(io.fabric8.kubernetes.api.model.HasMetadata obj) |
static long |
parseTimestamp(String timestamp) |
static void |
shutdownOpenShiftClient() |
static void |
updateGitSourceUrl(io.fabric8.openshift.api.model.BuildConfig buildConfig,
String gitUrl,
String ref)
Lazily creates the GitSource if need be then updates the git URL
|
public static void initializeOpenShiftClient(String serverUrl)
OpenShiftClientserverUrl - the optional URL of where the OpenShift cluster API server is runningpublic static io.fabric8.openshift.client.OpenShiftClient getOpenShiftClient()
public static void shutdownOpenShiftClient()
public static boolean isJenkinsBuildConfig(io.fabric8.openshift.api.model.BuildConfig bc)
BuildConfig relates to a Jenkins buildbc - the BuildConfigpublic static String jenkinsJobName(io.fabric8.openshift.api.model.BuildConfig bc, String defaultNamespace)
BuildConfig and defaultNamespacebc - the BuildConfigdefaultNamespace - the default namespace which does not prefix job names with "$namespace-buildConfigName"public static String jenkinsJobName(String namespace, String buildConfigName, String defaultNamespace)
namespace - the namespace of the buildbuildConfigName - the name of the BuildConfig in in the namespacedefaultNamespace - the default namespace that Jenkins is running inside, which
by doesn't prefix itself in front of jenkins job namespublic static String getNamespaceOrUseDefault(String configuredNamespace, io.fabric8.openshift.client.OpenShiftClient client)
configuredNamespace - the optional configured namespaceclient - the OpenShift clientpublic static String getExternalServiceUrl(io.fabric8.openshift.client.OpenShiftClient openShiftClient, String protocolText, String namespace, String serviceName)
openShiftClient - the OpenShiftClient to useprotocolText - the protocol text part of a URL such as http://namespace - the Kubernetes namespaceserviceName - the service namepublic static String getJenkinsURL(io.fabric8.openshift.client.OpenShiftClient openShiftClient, String namespace)
namespace - the namespace Jenkins is runing insideopenShiftClient - the OpenShift clientpublic static void updateGitSourceUrl(io.fabric8.openshift.api.model.BuildConfig buildConfig,
String gitUrl,
String ref)
buildConfig - the BuildConfig to updategitUrl - the URL to the git reporef - public static void cancelOpenShiftBuild(io.fabric8.openshift.api.model.Build build)
public static NamespaceName buildConfigNameFromJenkinsJobName(String jobName, String defaultNamespace)
jobName - the job to associate to a BuildConfig namedefaultNamespace - the default namespace that Jenkins is running insidepublic static long parseResourceVersion(io.fabric8.kubernetes.api.model.HasMetadata obj)
public static String formatTimestamp(long timestamp)
public static long parseTimestamp(String timestamp)
public static boolean isResourceWithoutStateEqual(io.fabric8.kubernetes.api.model.HasMetadata oldObj,
io.fabric8.kubernetes.api.model.HasMetadata newObj)
public static String dumpWithoutRuntimeStateAsYaml(io.fabric8.kubernetes.api.model.HasMetadata obj) throws com.fasterxml.jackson.core.JsonProcessingException
com.fasterxml.jackson.core.JsonProcessingExceptionCopyright © 2016 Red Hat. All rights reserved.