use of org.jboss.tools.openshift.cdk.server.core.internal.listeners.ServiceManagerEnvironmentLoader in project jbosstools-openshift by jbosstools.
the class CDKRegistryProvider method findServer.
private Pair findServer(IConnection connection) {
CDKOpenshiftUtility util = new CDKOpenshiftUtility();
IServer[] all = ServerCore.getServers();
MultiStatus ms = new MultiStatus(CDKCoreActivator.PLUGIN_ID, 0, "CDKRegistryProvider unable to locate a registry URL for openshift connection " + connection.toString(), null);
if (all.length == 0) {
ms.add(new Status(IStatus.ERROR, CDKCoreActivator.PLUGIN_ID, "No Servers exist in the workspace."));
}
boolean foundMinishift = false;
for (int i = 0; i < all.length; i++) {
ServiceManagerEnvironment env = getServiceManagerEnvironment(all[i]);
ServiceManagerEnvironmentLoader type = ServiceManagerEnvironmentLoader.type(all[i]);
if (type.getType() != ServiceManagerEnvironmentLoader.TYPE_MINISHIFT) {
continue;
}
foundMinishift = true;
if (all[i].getServerState() != IServer.STATE_STARTED) {
ms.add(new Status(IStatus.INFO, CDKCoreActivator.PLUGIN_ID, "Unable to locate the CDK environment details for stopped server " + all[i].getName()));
continue;
}
if (env == null) {
ms.add(new Status(IStatus.INFO, CDKCoreActivator.PLUGIN_ID, "Unable to locate the CDK environment details for server " + all[i].getName()));
continue;
}
if (!util.serverMatchesConnection(all[i], connection, env)) {
ms.add(util.serverConnectionMatchError(all[i], connection, env));
continue;
}
String registry = env.getDockerRegistry();
if (registry == null || registry.isEmpty()) {
String s = "Server {0} does not have a registry associated with it. Please verify that 'minishift openshift registry' returns a valid URL.";
ms.add(new Status(IStatus.INFO, CDKCoreActivator.PLUGIN_ID, NLS.bind(s, all[i].getName())));
continue;
}
return new Pair(null, all[i]);
}
if (all.length > 0 && !foundMinishift) {
ms.add(new Status(IStatus.ERROR, CDKCoreActivator.PLUGIN_ID, "No valid CDK Servers exist in the workspace."));
}
return new Pair(ms, null);
}
Aggregations