use of com.openshift.restclient.model.IProject in project jbosstools-openshift by jbosstools.
the class OpenShift3NativeProjectUtils method getOrCreateProject.
public static IProject getOrCreateProject(String name, String displayName, String description, Connection connection) {
IProject project = OpenShift3NativeResourceUtils.getProject(name, connection);
if (project == null) {
LOGGER.debug(NLS.bind("Project {0} doesnt exist yet in {1}, creating it.", name, connection.getHost()));
project = createProject(name, displayName, description, connection);
}
return project;
}
use of com.openshift.restclient.model.IProject in project jbosstools-openshift by jbosstools.
the class DeleteResourceHandlerTest method testStopWatchProject.
@Test
public void testStopWatchProject() throws Exception {
IProject project = mock(IProject.class);
when(project.getName()).thenReturn("ProjectName");
when(project.getKind()).thenReturn(ResourceKind.PROJECT);
IProjectWrapper projectWrapper = mock(IProjectWrapper.class);
when(projectWrapper.getWrapped()).thenReturn(project);
Connection connection = mock(Connection.class);
ConnectionsRegistrySingleton.getInstance().add(connection);
when(connection.ownsResource(project)).thenReturn(true);
WatchManager.getInstance().startWatch(project, connection);
assertEquals(WatchManager.KINDS.length, WatchManager.getInstance()._getWatches().size());
DeleteResourceHandlerTestExtension handler = new DeleteResourceHandlerTestExtension();
JobGroup deleteResourcesJobGroup = handler.deleteResources(new IResourceWrapper<?, ?>[] { projectWrapper });
deleteResourcesJobGroup.join(500, null);
assertEquals(0, WatchManager.getInstance()._getWatches().size());
}
use of com.openshift.restclient.model.IProject in project jbosstools-openshift by jbosstools.
the class DeployImageWizardModelTest method loadResources_should_load_projects.
@Test
public void loadResources_should_load_projects() {
// given
IProject project1 = mock(IProject.class);
IProject project2 = mock(IProject.class);
createModelProjects(this.connection, project1, project2);
model.setResourcesLoaded(false);
// when
model.loadResources();
// then
assertThat(model.getProjects()).isEqualTo(Arrays.asList(project1, project2));
}
use of com.openshift.restclient.model.IProject in project wildfly-swarm by wildfly-swarm.
the class NamespaceService method start.
@Override
public void start(StartContext context) throws StartException {
this.client = this.clientInjector.getValue();
this.namespace = System.getenv("KUBERNETES_NAMESPACE");
if (this.namespace == null) {
Path namespaceFile = Paths.get("/var/run/secrets/kubernetes.io/serviceaccount/namespace");
if (Files.exists(namespaceFile)) {
try {
this.namespace = new String(Files.readAllBytes(namespaceFile));
} catch (IOException ignored) {
// shouldn't happen, this file is on tmpfs
// but if it happened anyway, we'll try the following options
}
}
}
if (this.namespace == null) {
this.namespace = System.getenv("OPENSHIFT_BUILD_NAMESPACE");
}
if (this.namespace == null) {
List<IProject> projects = this.client.list(ResourceKind.PROJECT);
if (projects.size() != 1) {
throw new StartException("Unable to automatically detect the " + "Kubernetes namespace to use. Set the environment " + "variable KUBERNETES_NAMESPACE and try again.");
}
this.namespace = projects.get(0).getNamespace();
}
}
Aggregations