use of com.redhat.devtools.intellij.tektoncd.Constants.KIND_PIPELINE in project intellij-tekton by redhat-developer.
the class TknCli method findTaskUsages.
@Override
public List<RefUsage> findTaskUsages(String kind, String resource) throws IOException {
String jsonPathExpr = "jsonpath=\\\"{range .items[*]}{@.metadata.name}|{range .spec.tasks[*]}{.taskRef.kind},{.taskRef.name}|{end}{end}\\\"";
String result = ExecHelper.execute(command, envVars, "pipeline", "ls", "-n", getNamespace(), "-o", jsonPathExpr);
String[] resultSplitted = result.replace("\"", "").split("\\|");
List<RefUsage> usages = new ArrayList<>();
String pipeline = "";
for (String item : resultSplitted) {
if (!item.contains(",")) {
pipeline = item;
continue;
}
String[] kindName = item.split(",");
if (kindName.length == 2 && kindName[0].equalsIgnoreCase(kind) && kindName[1].equalsIgnoreCase(resource) && !pipeline.isEmpty()) {
String finalPipeline = pipeline;
Optional<RefUsage> refUsage = usages.stream().filter(ref -> ref.getKind().equals(KIND_PIPELINE) && ref.getName().equals(finalPipeline)).findFirst();
if (refUsage.isPresent()) {
refUsage.get().incremetOccurrence();
} else {
usages.add(new RefUsage(getNamespace(), pipeline, KIND_PIPELINE));
}
}
}
return usages;
}
Aggregations