Search in sources :

Example 21 with IDeploymentConfig

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;
}
Also used : ISelection(org.eclipse.jface.viewers.ISelection) IDeploymentConfig(com.openshift.restclient.model.IDeploymentConfig)

Example 22 with IDeploymentConfig

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);
}
Also used : DockerImageURI(com.openshift.restclient.images.DockerImageURI) Collection(java.util.Collection) IDeploymentConfig(com.openshift.restclient.model.IDeploymentConfig) IDeploymentTrigger(com.openshift.restclient.model.deploy.IDeploymentTrigger) IDeploymentImageChangeTrigger(com.openshift.restclient.model.deploy.IDeploymentImageChangeTrigger)

Example 23 with IDeploymentConfig

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;
}
Also used : IServiceWrapper(org.jboss.tools.openshift.internal.ui.models.IServiceWrapper) IDeploymentConfig(com.openshift.restclient.model.IDeploymentConfig) IResource(com.openshift.restclient.model.IResource) IPod(com.openshift.restclient.model.IPod) IReplicationController(com.openshift.restclient.model.IReplicationController)

Example 24 with IDeploymentConfig

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]);
}
Also used : Connection(org.jboss.tools.openshift.core.connection.Connection) IDeploymentConfig(com.openshift.restclient.model.IDeploymentConfig) IService(com.openshift.restclient.model.IService) Test(org.junit.Test)

Aggregations

IDeploymentConfig (com.openshift.restclient.model.IDeploymentConfig)24 Test (org.junit.Test)11 Connection (org.jboss.tools.openshift.core.connection.Connection)9 IResource (com.openshift.restclient.model.IResource)8 IService (com.openshift.restclient.model.IService)7 IDeploymentImageChangeTrigger (com.openshift.restclient.model.deploy.IDeploymentImageChangeTrigger)7 DockerImageURI (com.openshift.restclient.images.DockerImageURI)6 IProject (com.openshift.restclient.model.IProject)5 Collection (java.util.Collection)4 ResourceKind (com.openshift.restclient.ResourceKind)3 IImageStream (com.openshift.restclient.model.IImageStream)3 IReplicationController (com.openshift.restclient.model.IReplicationController)3 ArrayList (java.util.ArrayList)3 Collections (java.util.Collections)3 HashMap (java.util.HashMap)3 List (java.util.List)3 IServiceWrapper (org.jboss.tools.openshift.internal.ui.models.IServiceWrapper)3 IClient (com.openshift.restclient.IClient)2 IResourceFactory (com.openshift.restclient.IResourceFactory)2 IPod (com.openshift.restclient.model.IPod)2