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());
}
}
}
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;
}
Aggregations