use of com.redhat.devtools.intellij.tektoncd.tree.TriggerTemplateNode in project intellij-tekton by redhat-developer.
the class TreeHelper method getYAMLAndKindFromNode.
/**
* Get YAML and Tekton kind from Tekton tree node.
*
* @param node the Tekton tree node
* @return Pair where 'first' is YAML content and 'second' is Tekton kind
*/
public static Pair<String, String> getYAMLAndKindFromNode(ParentableNode<?> node) {
Pair<String, String> yamlAndKind = null;
try {
String namespace = node.getNamespace();
Tkn tkncli = node.getRoot().getTkn();
String content = "";
String kind = "";
if (node instanceof PipelineNode) {
content = tkncli.getPipelineYAML(namespace, node.getName());
kind = KIND_PIPELINES;
} else if (node instanceof ResourceNode) {
content = tkncli.getResourceYAML(namespace, node.getName());
kind = KIND_RESOURCES;
} else if (node instanceof TaskNode) {
content = tkncli.getTaskYAML(namespace, node.getName());
kind = KIND_TASKS;
} else if (node instanceof ClusterTaskNode) {
content = tkncli.getClusterTaskYAML(node.getName());
kind = KIND_CLUSTERTASKS;
} else if (node instanceof ConditionNode) {
content = tkncli.getConditionYAML(namespace, node.getName());
kind = KIND_CONDITIONS;
} else if (node instanceof TriggerTemplateNode) {
content = tkncli.getTriggerTemplateYAML(namespace, node.getName());
kind = KIND_TRIGGERTEMPLATES;
} else if (node instanceof TriggerBindingNode) {
content = tkncli.getTriggerBindingYAML(namespace, node.getName());
kind = KIND_TRIGGERBINDINGS;
} else if (node instanceof ClusterTriggerBindingNode) {
content = tkncli.getClusterTriggerBindingYAML(node.getName());
kind = KIND_CLUSTERTRIGGERBINDINGS;
} else if (node instanceof EventListenerNode) {
content = tkncli.getEventListenerYAML(namespace, node.getName());
kind = KIND_EVENTLISTENERS;
} else if (node instanceof TaskRunNode) {
content = tkncli.getTaskRunYAML(namespace, node.getName());
kind = KIND_TASKRUN;
} else if (node instanceof PipelineRunNode) {
content = tkncli.getPipelineRunYAML(namespace, node.getName());
kind = KIND_PIPELINERUN;
}
yamlAndKind = Pair.create(content, kind);
} catch (IOException e) {
UIHelper.executeInUI(() -> Messages.showErrorDialog("Error: " + e.getLocalizedMessage(), "Error"));
}
return yamlAndKind;
}
Aggregations