Search in sources :

Example 1 with ClusterTasksNode

use of com.redhat.devtools.intellij.tektoncd.tree.ClusterTasksNode in project intellij-tekton by redhat-developer.

the class WatchNodes method setWatchByNode.

public void setWatchByNode(ParentableNode<?> element) {
    String namespace = element.getNamespace();
    String watchId = getWatchId(element);
    Watch watch = null;
    WatchNodes wn = null;
    // (e.g a taskRuns watcher, when a change happens, could update multiple nodes such as a single Task node and the TaskRuns node)
    if (this.watches.containsKey(watchId)) {
        wn = this.watches.get(watchId);
        if (wn.getNodes().stream().noneMatch(item -> item.getName().equalsIgnoreCase(element.getName()) && ((ParentableNode) item.getParent()).getName().equalsIgnoreCase(((ParentableNode) element.getParent()).getName()))) {
            wn.getNodes().add(element);
        }
        return;
    }
    Watcher watcher = getWatcher(watchId, element.getRoot().getProject());
    try {
        if (element instanceof PipelinesNode) {
            watch = tkn.watchPipelines(namespace, watcher);
        } else if (element instanceof PipelineNode) {
            // we are expanding a single pipeline node and we want it to refresh if its children (pipelineruns) change
            watch = tkn.watchPipelineRuns(namespace, watcher);
        } else if (element instanceof PipelineRunsNode) {
            watch = tkn.watchPipelineRuns(namespace, watcher);
        } else if (element instanceof PipelineRunNode) {
            // we are expanding a single pipelinerun node and we want it to refresh if its children (taskruns) change
            watch = tkn.watchTaskRuns(namespace, watcher);
        } else if (element instanceof ResourcesNode) {
            watch = tkn.watchPipelineResources(namespace, watcher);
        } else if (element instanceof TasksNode) {
            watch = tkn.watchTasks(namespace, watcher);
        } else if (element instanceof TaskNode) {
            // we are expanding a single task node and we want it to refresh if its children (taskruns) change
            watch = tkn.watchTaskRuns(namespace, watcher);
        } else if (element instanceof TaskRunsNode) {
            watch = tkn.watchTaskRuns(namespace, watcher);
        } else if (element instanceof ClusterTasksNode) {
            watch = tkn.watchClusterTasks(watcher);
        } else if (element instanceof ConditionsNode) {
            watch = tkn.watchConditions(namespace, watcher);
        } else if (element instanceof TriggerTemplatesNode) {
            watch = tkn.watchTriggerTemplates(namespace, watcher);
        } else if (element instanceof TriggerBindingsNode) {
            watch = tkn.watchTriggerBindings(namespace, watcher);
        } else if (element instanceof ClusterTriggerBindingsNode) {
            watch = tkn.watchClusterTriggerBindings(watcher);
        } else if (element instanceof EventListenersNode) {
            watch = tkn.watchEventListeners(namespace, watcher);
        }
        wn = new WatchNodes(watch, element);
    } catch (IOException e) {
        logger.warn("Error: " + e.getLocalizedMessage(), e);
    }
    if (wn != null) {
        watches.put(watchId, wn);
    }
}
Also used : PipelinesNode(com.redhat.devtools.intellij.tektoncd.tree.PipelinesNode) TaskNode(com.redhat.devtools.intellij.tektoncd.tree.TaskNode) ClusterTriggerBindingsNode(com.redhat.devtools.intellij.tektoncd.tree.ClusterTriggerBindingsNode) Watcher(io.fabric8.kubernetes.client.Watcher) IOException(java.io.IOException) PipelineNode(com.redhat.devtools.intellij.tektoncd.tree.PipelineNode) ResourcesNode(com.redhat.devtools.intellij.tektoncd.tree.ResourcesNode) ClusterTriggerBindingsNode(com.redhat.devtools.intellij.tektoncd.tree.ClusterTriggerBindingsNode) TriggerBindingsNode(com.redhat.devtools.intellij.tektoncd.tree.TriggerBindingsNode) PipelineRunsNode(com.redhat.devtools.intellij.tektoncd.tree.PipelineRunsNode) PipelineRunNode(com.redhat.devtools.intellij.tektoncd.tree.PipelineRunNode) TasksNode(com.redhat.devtools.intellij.tektoncd.tree.TasksNode) ClusterTasksNode(com.redhat.devtools.intellij.tektoncd.tree.ClusterTasksNode) EventListenersNode(com.redhat.devtools.intellij.tektoncd.tree.EventListenersNode) Watch(io.fabric8.kubernetes.client.Watch) TriggerTemplatesNode(com.redhat.devtools.intellij.tektoncd.tree.TriggerTemplatesNode) ConditionsNode(com.redhat.devtools.intellij.tektoncd.tree.ConditionsNode) TaskRunsNode(com.redhat.devtools.intellij.tektoncd.tree.TaskRunsNode) ClusterTasksNode(com.redhat.devtools.intellij.tektoncd.tree.ClusterTasksNode)

Example 2 with ClusterTasksNode

use of com.redhat.devtools.intellij.tektoncd.tree.ClusterTasksNode in project intellij-tekton by redhat-developer.

the class HubModelTest method setUp.

@Before
public void setUp() throws Exception {
    super.setUp();
    watch = mock(Watch.class);
    when(tkn.getNamespace()).thenReturn("namespace");
    when(tkn.watchPipelines(anyString(), any())).thenReturn(watch);
    when(tkn.watchTasks(anyString(), any())).thenReturn(watch);
    when(tkn.watchClusterTasks(any())).thenReturn(watch);
    pipelinesNode = mock(PipelinesNode.class);
    clusterTasksNode = mock(ClusterTasksNode.class);
    recognizerFactory = mock(RecognizerFactory.class);
    languageRecognizer = mock(LanguageRecognizer.class);
    when(recognizerFactory.createLanguageRecognizer()).thenReturn(languageRecognizer);
    languageJAVA = new Language("java", Collections.emptyList(), 1.0, true);
    languageUnknown = new Language("Unknown", Collections.emptyList(), 1.0, false);
    resourceApi = mock(ResourceApi.class);
    resourceDataJAVA = mock(ResourceData.class);
    resourceVersionDataJAVA = mock(ResourceVersionData.class);
    when(resourceDataJAVA.getName()).thenReturn("java");
    when(resourceDataJAVA.getKind()).thenReturn(KIND_TASK);
    when(resourceDataJAVA.getLatestVersion()).thenReturn(resourceVersionDataJAVA);
    when(resourceVersionDataJAVA.getVersion()).thenReturn("v1");
    resourceDataGO = mock(ResourceData.class);
    resourceVersionDataGO = mock(ResourceVersionData.class);
    when(resourceDataGO.getName()).thenReturn("go");
    when(resourceDataGO.getKind()).thenReturn(KIND_TASK);
    when(resourceDataGO.getLatestVersion()).thenReturn(resourceVersionDataGO);
    when(resourceVersionDataGO.getVersion()).thenReturn("v1");
    resourceDataNET = mock(ResourceData.class);
    resourceVersionDataNET = mock(ResourceVersionData.class);
    when(resourceDataNET.getName()).thenReturn("net");
    when(resourceDataNET.getKind()).thenReturn(KIND_PIPELINE);
    when(resourceDataNET.getLatestVersion()).thenReturn(resourceVersionDataNET);
    when(resourceVersionDataNET.getVersion()).thenReturn("v1");
    when(project.getBasePath()).thenReturn(".");
    resources = new Resources();
    resources.addDataItem(resourceDataJAVA);
    resources.addDataItem(resourceDataGO);
}
Also used : PipelinesNode(com.redhat.devtools.intellij.tektoncd.tree.PipelinesNode) ResourceApi(com.redhat.devtools.intellij.tektoncd.hub.api.ResourceApi) ResourceData(com.redhat.devtools.intellij.tektoncd.hub.model.ResourceData) LanguageRecognizer(com.redhat.devtools.alizer.api.LanguageRecognizer) Language(com.redhat.devtools.alizer.api.Language) ResourceVersionData(com.redhat.devtools.intellij.tektoncd.hub.model.ResourceVersionData) Watch(io.fabric8.kubernetes.client.Watch) RecognizerFactory(com.redhat.devtools.alizer.api.RecognizerFactory) Resources(com.redhat.devtools.intellij.tektoncd.hub.model.Resources) ClusterTasksNode(com.redhat.devtools.intellij.tektoncd.tree.ClusterTasksNode) Before(org.junit.Before)

Example 3 with ClusterTasksNode

use of com.redhat.devtools.intellij.tektoncd.tree.ClusterTasksNode in project intellij-tekton by redhat-developer.

the class CreateClusterTaskAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent anActionEvent, TreePath path, Object selected, Tkn tkncli) {
    ActionMessage telemetry = TelemetryService.instance().action(NAME_PREFIX_CRUD + "create cluster task").property(PROP_RESOURCE_KIND, KIND_CLUSTERTASK);
    ClusterTasksNode item = getElement(selected);
    String namespace = item.getParent().getName();
    String content = getSnippet("Tekton: ClusterTask");
    if (Strings.isNullOrEmpty(content)) {
        telemetry.error("snippet content empty").send();
    } else {
        String name = "newclustertask.yaml";
        try {
            VirtualFileHelper.createAndOpenVirtualFile(anActionEvent.getProject(), namespace, name, content, KIND_CLUSTERTASKS, item);
            telemetry.success().send();
        } catch (IOException e) {
            String errorMessage = "Could not create cluster cluster task: " + e.getLocalizedMessage();
            telemetry.error(anonymizeResource(name, namespace, errorMessage)).send();
            logger.warn(errorMessage, e);
        }
    }
}
Also used : ActionMessage(com.redhat.devtools.intellij.telemetry.core.service.TelemetryMessageBuilder.ActionMessage) IOException(java.io.IOException) ClusterTasksNode(com.redhat.devtools.intellij.tektoncd.tree.ClusterTasksNode)

Aggregations

ClusterTasksNode (com.redhat.devtools.intellij.tektoncd.tree.ClusterTasksNode)3 PipelinesNode (com.redhat.devtools.intellij.tektoncd.tree.PipelinesNode)2 Watch (io.fabric8.kubernetes.client.Watch)2 IOException (java.io.IOException)2 Language (com.redhat.devtools.alizer.api.Language)1 LanguageRecognizer (com.redhat.devtools.alizer.api.LanguageRecognizer)1 RecognizerFactory (com.redhat.devtools.alizer.api.RecognizerFactory)1 ResourceApi (com.redhat.devtools.intellij.tektoncd.hub.api.ResourceApi)1 ResourceData (com.redhat.devtools.intellij.tektoncd.hub.model.ResourceData)1 ResourceVersionData (com.redhat.devtools.intellij.tektoncd.hub.model.ResourceVersionData)1 Resources (com.redhat.devtools.intellij.tektoncd.hub.model.Resources)1 ClusterTriggerBindingsNode (com.redhat.devtools.intellij.tektoncd.tree.ClusterTriggerBindingsNode)1 ConditionsNode (com.redhat.devtools.intellij.tektoncd.tree.ConditionsNode)1 EventListenersNode (com.redhat.devtools.intellij.tektoncd.tree.EventListenersNode)1 PipelineNode (com.redhat.devtools.intellij.tektoncd.tree.PipelineNode)1 PipelineRunNode (com.redhat.devtools.intellij.tektoncd.tree.PipelineRunNode)1 PipelineRunsNode (com.redhat.devtools.intellij.tektoncd.tree.PipelineRunsNode)1 ResourcesNode (com.redhat.devtools.intellij.tektoncd.tree.ResourcesNode)1 TaskNode (com.redhat.devtools.intellij.tektoncd.tree.TaskNode)1 TaskRunsNode (com.redhat.devtools.intellij.tektoncd.tree.TaskRunsNode)1