use of com.redhat.devtools.intellij.tektoncd.tkn.component.field.Workspace in project intellij-tekton by redhat-developer.
the class TknCliTest method checkRightArgsWhenStartingClusterTaskWithMultipleInputs.
@Test
public void checkRightArgsWhenStartingClusterTaskWithMultipleInputs() throws IOException {
Map<String, Input> params = new HashMap<>();
params.put("param1", new Input("param1", "string", Input.Kind.PARAMETER, "value1", Optional.empty(), Optional.empty()));
Map<String, String> inputResources = new HashMap<>();
inputResources.put("res1", "value1");
inputResources.put("res2", "value2");
Map<String, String> outputResources = new HashMap<>();
outputResources.put("out1", "value1");
Map<String, Workspace> workspaces = new HashMap<>();
workspaces.put("work1", new Workspace("work1", Workspace.Kind.PVC, "value1"));
workspaces.put("work2", new Workspace("work2", Workspace.Kind.SECRET, "value2"));
MockedStatic<ExecHelper> exec = mockStatic(ExecHelper.class);
exec.when(() -> ExecHelper.execute(anyString(), anyMap(), any())).thenReturn("");
tkn.startClusterTask("ns", "name", params, inputResources, outputResources, "sa", workspaces, "prefix");
exec.verify(() -> ExecHelper.execute(anyString(), anyMap(), eq("clustertask"), eq("start"), eq("name"), eq("-n"), eq("ns"), eq("-s=sa"), eq("-w"), eq("name=work2,secret=value2"), eq("-w"), eq("name=work1,claimName=value1"), eq("-p"), eq("param1=value1"), eq("-i"), eq("res1=value1"), eq("-i"), eq("res2=value2"), eq("-o"), eq("out1=value1"), eq("--prefix-name=prefix"), eq(FLAG_SKIP_OPTIONAL_WORKSPACES)));
exec.close();
}
use of com.redhat.devtools.intellij.tektoncd.tkn.component.field.Workspace in project intellij-tekton by redhat-developer.
the class YAMLBuilderTest method checkTaskRunCreatedHasWorkspace.
@Test
public void checkTaskRunCreatedHasWorkspace() throws IOException {
String content = load("task10.yaml");
AddTriggerModel model = new AddTriggerModel(content, Collections.emptyList(), Collections.emptyList(), Collections.emptyList(), Collections.emptyList(), Collections.emptyList(), Collections.emptyMap());
if (model.getWorkspaces().containsKey("write-allowed")) {
model.getWorkspaces().put("write-allowed", new Workspace("foo1", Workspace.Kind.EMPTYDIR, "foo"));
}
if (model.getWorkspaces().containsKey("write-disallowed")) {
model.getWorkspaces().put("write-disallowed", new Workspace("foo2", Workspace.Kind.EMPTYDIR, "foo"));
}
ObjectNode taskRunNode = YAMLBuilder.createTaskRun(model);
assertEquals(taskRunNode.get("apiVersion").asText(), "tekton.dev/v1beta1");
assertEquals(taskRunNode.get("kind").asText(), "TaskRun");
assertEquals(taskRunNode.get("metadata").get("generateName").asText(), "foo-");
assertEquals(taskRunNode.get("spec").get("taskRef").get("name").asText(), "foo");
assertFalse(taskRunNode.get("spec").has("serviceAccountName"));
assertFalse(taskRunNode.get("spec").has("serviceAccountNames"));
assertFalse(taskRunNode.get("spec").has("params"));
assertFalse(taskRunNode.get("spec").has("resources"));
assertTrue(taskRunNode.get("spec").has("workspaces"));
assertEquals(taskRunNode.get("spec").get("workspaces").get(0).get("name").asText(), "foo1");
assertEquals(taskRunNode.get("spec").get("workspaces").get(1).get("name").asText(), "foo2");
}
use of com.redhat.devtools.intellij.tektoncd.tkn.component.field.Workspace in project intellij-tekton by redhat-developer.
the class YAMLBuilderTest method checkPipelineRunCreatedHasWorkspace.
@Test
public void checkPipelineRunCreatedHasWorkspace() throws IOException {
String content = load("pipeline5.yaml");
AddTriggerModel model = new AddTriggerModel(content, Collections.emptyList(), Collections.emptyList(), Collections.emptyList(), Collections.emptyList(), Collections.emptyList(), Collections.emptyMap());
if (model.getWorkspaces().containsKey("password-vault")) {
model.getWorkspaces().put("password-vault", new Workspace("foo1", Workspace.Kind.EMPTYDIR, "foo"));
}
if (model.getWorkspaces().containsKey("recipe-store")) {
model.getWorkspaces().put("recipe-store", new Workspace("foo2", Workspace.Kind.EMPTYDIR, "foo"));
}
ObjectNode pipelineRunNode = YAMLBuilder.createPipelineRun(model);
assertEquals(pipelineRunNode.get("apiVersion").asText(), "tekton.dev/v1beta1");
assertEquals(pipelineRunNode.get("kind").asText(), "PipelineRun");
assertEquals(pipelineRunNode.get("metadata").get("generateName").asText(), "foo-");
assertEquals(pipelineRunNode.get("spec").get("pipelineRef").get("name").asText(), "foo");
assertFalse(pipelineRunNode.get("spec").has("serviceAccountName"));
assertFalse(pipelineRunNode.get("spec").has("serviceAccountNames"));
assertFalse(pipelineRunNode.get("spec").has("params"));
assertFalse(pipelineRunNode.get("spec").has("resources"));
assertTrue(pipelineRunNode.get("spec").has("workspaces"));
assertEquals(pipelineRunNode.get("spec").get("workspaces").get(0).get("name").asText(), "foo1");
assertEquals(pipelineRunNode.get("spec").get("workspaces").get(1).get("name").asText(), "foo2");
}
use of com.redhat.devtools.intellij.tektoncd.tkn.component.field.Workspace in project intellij-tekton by redhat-developer.
the class TektonAction method createNewVolumes.
protected void createNewVolumes(Map<String, Workspace> workspaces, Tkn tkn) throws IOException {
int counter = 0;
for (Map.Entry<String, Workspace> entry : workspaces.entrySet()) {
Workspace workspace = entry.getValue();
if (workspace != null && workspace.getKind() == Workspace.Kind.PVC && workspace.getResource().isEmpty() && workspace.getItems().size() > 0) {
if (KIND_VCT.equals(workspace.getItems().get("type"))) {
VirtualFile vf = createVCT(workspace.getItems(), counter);
workspace.getItems().put("file", vf.getPath());
counter++;
} else {
String name = createNewPVC(workspace.getItems(), tkn);
workspace.setResource(name);
}
}
}
}
Aggregations