use of com.openshift.restclient.model.IDeploymentConfig in project jbosstools-openshift by jbosstools.
the class TriggerDeploymentHandler method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
ISelection selection = UIUtils.getCurrentSelection(event);
IDeploymentConfig resource = retrieveDeploymentConfig(selection);
if (resource == null) {
MessageDialog.openInformation(HandlerUtil.getActiveShell(event), "Trigger Deployment", "A deployment or deployment config must be selected in order to trigger a new deployment.");
return null;
}
scheduleJob(resource);
return null;
}
use of com.openshift.restclient.model.IDeploymentConfig in project jbosstools-openshift by jbosstools.
the class DeployImageJobTest method givenTheDeploymentConfigExistFor.
private void givenTheDeploymentConfigExistFor(String name, String tag, String triggerNamespace, String triggerKind) {
IDeploymentImageChangeTrigger trigger = mock(IDeploymentImageChangeTrigger.class);
when(trigger.getType()).thenReturn(DeploymentTriggerType.IMAGE_CHANGE);
when(trigger.getNamespace()).thenReturn(triggerNamespace);
when(trigger.getKind()).thenReturn(triggerKind);
when(trigger.getFrom()).thenReturn(new DockerImageURI(null, null, name, tag));
IDeploymentConfig dc = createResource(IDeploymentConfig.class, ResourceKind.DEPLOYMENT_CONFIG, new IResourceVisitor<IDeploymentConfig>() {
@Override
public void visit(IDeploymentConfig resource) {
Collection<IDeploymentTrigger> triggers = new ArrayList<IDeploymentTrigger>();
triggers.add(trigger);
when(resource.getTriggers()).thenReturn(triggers);
}
});
when(connection.getResource(ResourceKind.DEPLOYMENT_CONFIG, project.getName(), parameters.getResourceName())).thenReturn(dc);
}
use of com.openshift.restclient.model.IDeploymentConfig in project jbosstools-openshift by jbosstools.
the class ScaleDeploymentHandler method getDeploymentConfig.
private IDeploymentConfig getDeploymentConfig(IResourceWrapper<?, ?> wrapper) {
if (wrapper == null) {
return null;
}
IDeploymentConfig dc = null;
IResource wrapped = wrapper.getWrapped();
if (wrapper instanceof IServiceWrapper) {
// service selected
dc = getDeploymentConfig((IServiceWrapper) wrapper);
} else if (wrapped instanceof IPod) {
// pod selected
dc = getDeploymentConfig((IPod) wrapped, wrapper);
} else if (wrapped instanceof IDeploymentConfig) {
// deployment config selected
// has to be tested before IReplicationController, IDeploymentConfig extends IReplicationController
dc = (IDeploymentConfig) wrapped;
} else if (wrapped instanceof IReplicationController) {
// replication controller selected (deployment tab in properties)
// has to be tested after IDeploymentConfig, IDeploymentConfig extends IReplicationController
dc = getDeploymentConfig((IReplicationController) wrapped, wrapper);
}
return dc;
}
use of com.openshift.restclient.model.IDeploymentConfig in project jbosstools-openshift by jbosstools.
the class ResourceUtilsTest method shouldReturnDeploymentConfigForServiceByRCAndPodGivenServiceHasNoDCNameSelector.
@Test
public void shouldReturnDeploymentConfigForServiceByRCAndPodGivenServiceHasNoDCNameSelector() throws CoreException {
// given
Connection connection = ResourceMocks.create3ProjectsConnection();
IService service = ResourceMocks.PROJECT2_SERVICES[2];
// when
IDeploymentConfig dc = ResourceUtils.getDeploymentConfigFor(service, connection);
// then
assertThat(dc).isEqualTo(ResourceMocks.PROJECT2_DEPLOYMENTCONFIGS[0]);
}
Aggregations