Search in sources :

Example 1 with Output

use of com.redhat.devtools.intellij.tektoncd.tkn.component.field.Output in project intellij-tekton by redhat-developer.

the class ActionToRunModel method setDefaultValueResources.

private void setDefaultValueResources() {
    if (this.pipelineResources == null || this.pipelineResources.isEmpty()) {
        if (!this.getInputResources().isEmpty() || !this.getOutputResources().isEmpty()) {
            errorMessage += " * The " + this.kind + " requires resources to be started but no resources were found in the cluster.\n";
            isValid = false;
        }
    }
    // set the first resource for a specific type (git, image, ...) as the default value for input/output
    Map<String, List<Resource>> resourceGroupedByType = pipelineResources.stream().collect(Collectors.groupingBy(Resource::type));
    if (!this.resource.getInputResources().isEmpty()) {
        for (Input input : this.resource.getInputResources()) {
            List<Resource> resourcesByInputType = resourceGroupedByType.get(input.type());
            if (resourcesByInputType == null) {
                errorMessage += " * The input " + input.name() + " requires a resource of type " + input.type() + " but no resource of that type was found in the cluster.\n";
                isValid = false;
                continue;
            }
            input.setValue(resourcesByInputType.get(0).name());
        }
    }
    if (!this.resource.getOutputResources().isEmpty()) {
        for (Output output : this.resource.getOutputResources()) {
            List<Resource> resourcesByOutputType = resourceGroupedByType.get(output.type());
            if (resourcesByOutputType == null) {
                errorMessage += " * The output " + output.name() + " requires a resource of type " + output.type() + " but no resource of that type was found in the cluster.\n";
                isValid = false;
                continue;
            }
            output.setValue(resourcesByOutputType.get(0).name());
        }
    }
}
Also used : Input(com.redhat.devtools.intellij.tektoncd.tkn.component.field.Input) Output(com.redhat.devtools.intellij.tektoncd.tkn.component.field.Output) Resource(com.redhat.devtools.intellij.tektoncd.tkn.Resource) List(java.util.List)

Example 2 with Output

use of com.redhat.devtools.intellij.tektoncd.tkn.component.field.Output in project intellij-tekton by redhat-developer.

the class YAMLBuilder method createOutputResourcesNode.

private static ArrayNode createOutputResourcesNode(List<Output> outputs) {
    ArrayNode resourcesNode = YAML_MAPPER.createArrayNode();
    ObjectNode outputNode;
    for (Output output : outputs) {
        outputNode = YAML_MAPPER.createObjectNode();
        outputNode.put("name", output.name());
        // resourceRef node
        ObjectNode resourceRefNode = YAML_MAPPER.createObjectNode();
        resourceRefNode.put("name", output.value() == null ? "Resource has not yet been inserted" : output.value());
        outputNode.set("resourceRef", resourceRefNode);
        resourcesNode.add(outputNode);
    }
    return resourcesNode;
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) Output(com.redhat.devtools.intellij.tektoncd.tkn.component.field.Output) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode)

Aggregations

Output (com.redhat.devtools.intellij.tektoncd.tkn.component.field.Output)2 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)1 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 Resource (com.redhat.devtools.intellij.tektoncd.tkn.Resource)1 Input (com.redhat.devtools.intellij.tektoncd.tkn.component.field.Input)1 List (java.util.List)1