Search in sources :

Example 1 with KIND_PIPELINERUN

use of com.redhat.devtools.intellij.tektoncd.Constants.KIND_PIPELINERUN in project intellij-tekton by redhat-developer.

the class YAMLBuilder method createRunInternal.

public static ObjectNode createRunInternal(String kind, ConfigurationModel model, boolean toDebug) {
    ObjectNode rootNode = YAML_MAPPER.createObjectNode();
    rootNode.put("apiVersion", "tekton.dev/v1beta1");
    rootNode.put("kind", kind);
    ObjectNode metadataNode = YAML_MAPPER.createObjectNode();
    metadataNode.put("generateName", model.getName() + "-");
    rootNode.set("metadata", metadataNode);
    ObjectNode spec = YAML_MAPPER.createObjectNode();
    if (model instanceof ActionToRunModel) {
        ActionToRunModel actionModel = (ActionToRunModel) model;
        if (kind.equalsIgnoreCase(KIND_PIPELINERUN)) {
            spec = createPipelineRunSpec(actionModel);
        } else {
            spec = createTaskRunSpec(actionModel.getResource().getName(), actionModel.getParams(), actionModel.getInputResources(), actionModel.getOutputResources(), actionModel.getWorkspaces(), actionModel.getServiceAccount().isEmpty() ? null : actionModel.getServiceAccount(), toDebug);
        }
    } else if (model instanceof TaskConfigurationModel) {
        Map<String, Workspace> workspaces = new HashMap<>();
        ((TaskConfigurationModel) model).getWorkspaces().stream().forEach(workspace -> {
            workspace.setKind(Workspace.Kind.EMPTYDIR);
            workspaces.put(workspace.getName(), workspace);
        });
        spec = createTaskRunSpec(model.getName(), ((TaskConfigurationModel) model).getParams(), ((TaskConfigurationModel) model).getInputResources(), ((TaskConfigurationModel) model).getOutputResources(), workspaces, "", toDebug);
    }
    rootNode.set("spec", spec);
    return rootNode;
}
Also used : WRITE_DOC_START_MARKER(com.fasterxml.jackson.dataformat.yaml.YAMLGenerator.Feature.WRITE_DOC_START_MARKER) ActionToRunModel(com.redhat.devtools.intellij.tektoncd.utils.model.actions.ActionToRunModel) YAMLHelper(com.redhat.devtools.intellij.common.utils.YAMLHelper) KIND_VCT(com.redhat.devtools.intellij.tektoncd.Constants.KIND_VCT) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Output(com.redhat.devtools.intellij.tektoncd.tkn.component.field.Output) Workspace(com.redhat.devtools.intellij.tektoncd.tkn.component.field.Workspace) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) IOException(java.io.IOException) HashMap(java.util.HashMap) KIND_PIPELINERUN(com.redhat.devtools.intellij.tektoncd.Constants.KIND_PIPELINERUN) HasMetadata(io.fabric8.kubernetes.api.model.HasMetadata) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) TaskConfigurationModel(com.redhat.devtools.intellij.tektoncd.utils.model.resources.TaskConfigurationModel) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) ConfigurationModel(com.redhat.devtools.intellij.tektoncd.utils.model.ConfigurationModel) List(java.util.List) YAMLMapper(com.fasterxml.jackson.dataformat.yaml.YAMLMapper) KIND_PVC(com.redhat.devtools.intellij.tektoncd.Constants.KIND_PVC) Map(java.util.Map) Pair(com.intellij.openapi.util.Pair) Input(com.redhat.devtools.intellij.tektoncd.tkn.component.field.Input) JsonNode(com.fasterxml.jackson.databind.JsonNode) KIND_PIPELINE(com.redhat.devtools.intellij.tektoncd.Constants.KIND_PIPELINE) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) TaskConfigurationModel(com.redhat.devtools.intellij.tektoncd.utils.model.resources.TaskConfigurationModel) HashMap(java.util.HashMap) Map(java.util.Map) ActionToRunModel(com.redhat.devtools.intellij.tektoncd.utils.model.actions.ActionToRunModel)

Aggregations

JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)1 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 WRITE_DOC_START_MARKER (com.fasterxml.jackson.dataformat.yaml.YAMLGenerator.Feature.WRITE_DOC_START_MARKER)1 YAMLMapper (com.fasterxml.jackson.dataformat.yaml.YAMLMapper)1 Pair (com.intellij.openapi.util.Pair)1 YAMLHelper (com.redhat.devtools.intellij.common.utils.YAMLHelper)1 KIND_PIPELINE (com.redhat.devtools.intellij.tektoncd.Constants.KIND_PIPELINE)1 KIND_PIPELINERUN (com.redhat.devtools.intellij.tektoncd.Constants.KIND_PIPELINERUN)1 KIND_PVC (com.redhat.devtools.intellij.tektoncd.Constants.KIND_PVC)1 KIND_VCT (com.redhat.devtools.intellij.tektoncd.Constants.KIND_VCT)1 Input (com.redhat.devtools.intellij.tektoncd.tkn.component.field.Input)1 Output (com.redhat.devtools.intellij.tektoncd.tkn.component.field.Output)1 Workspace (com.redhat.devtools.intellij.tektoncd.tkn.component.field.Workspace)1 ConfigurationModel (com.redhat.devtools.intellij.tektoncd.utils.model.ConfigurationModel)1 ActionToRunModel (com.redhat.devtools.intellij.tektoncd.utils.model.actions.ActionToRunModel)1 TaskConfigurationModel (com.redhat.devtools.intellij.tektoncd.utils.model.resources.TaskConfigurationModel)1 HasMetadata (io.fabric8.kubernetes.api.model.HasMetadata)1