Search in sources :

Example 6 with PipelineConfigurationModel

use of com.redhat.devtools.intellij.tektoncd.utils.model.resources.PipelineConfigurationModel in project intellij-tekton by redhat-developer.

the class TaskReferencesInspector method checkFile.

@Nullable
@Override
public ProblemDescriptor[] checkFile(@NotNull PsiFile file, @NotNull InspectionManager manager, boolean isOnTheFly) {
    ConfigurationModel model = getTektonModelFromFile(file);
    if (model == null) {
        return ProblemDescriptor.EMPTY_ARRAY;
    }
    List<PsiElement> tasKNotFoundPsiElements = new ArrayList<>();
    if (model instanceof PipelineConfigurationModel) {
        List<String> tasksOnCluster = getTasksOnCluster(file.getProject(), model.getNamespace());
        tasKNotFoundPsiElements = findTaskElementsNotFoundOnCluster(file, tasksOnCluster);
    }
    return tasKNotFoundPsiElements.stream().map(item -> manager.createProblemDescriptor(item, item, "No task named " + StringHelper.getUnquotedValueFromPsi(item) + " found on cluster.", ProblemHighlightType.GENERIC_ERROR, isOnTheFly)).toArray(ProblemDescriptor[]::new);
}
Also used : PipelineConfigurationModel(com.redhat.devtools.intellij.tektoncd.utils.model.resources.PipelineConfigurationModel) Logger(org.slf4j.Logger) TreeHelper(com.redhat.devtools.intellij.tektoncd.utils.TreeHelper) LoggerFactory(org.slf4j.LoggerFactory) IOException(java.io.IOException) PipelineConfigurationModel(com.redhat.devtools.intellij.tektoncd.utils.model.resources.PipelineConfigurationModel) ArrayList(java.util.ArrayList) ASTNode(com.intellij.lang.ASTNode) Tkn(com.redhat.devtools.intellij.tektoncd.tkn.Tkn) Nullable(org.jetbrains.annotations.Nullable) ConfigurationModel(com.redhat.devtools.intellij.tektoncd.utils.model.ConfigurationModel) List(java.util.List) InspectionManager(com.intellij.codeInspection.InspectionManager) ProblemDescriptor(com.intellij.codeInspection.ProblemDescriptor) PsiElement(com.intellij.psi.PsiElement) Project(com.intellij.openapi.project.Project) PsiFile(com.intellij.psi.PsiFile) StringHelper(com.redhat.devtools.intellij.common.utils.StringHelper) ProblemHighlightType(com.intellij.codeInspection.ProblemHighlightType) Pattern(java.util.regex.Pattern) NotNull(org.jetbrains.annotations.NotNull) Collections(java.util.Collections) PipelineConfigurationModel(com.redhat.devtools.intellij.tektoncd.utils.model.resources.PipelineConfigurationModel) ConfigurationModel(com.redhat.devtools.intellij.tektoncd.utils.model.ConfigurationModel) ArrayList(java.util.ArrayList) PsiElement(com.intellij.psi.PsiElement) Nullable(org.jetbrains.annotations.Nullable)

Example 7 with PipelineConfigurationModel

use of com.redhat.devtools.intellij.tektoncd.utils.model.resources.PipelineConfigurationModel in project intellij-tekton by redhat-developer.

the class ConfigurationModelFactoryTest method checkPipelineModelIsReturned.

@Test
public void checkPipelineModelIsReturned() throws IOException {
    String configuration = load("pipeline1.yaml");
    ConfigurationModel model = ConfigurationModelFactory.getModel(configuration);
    assertTrue(model instanceof PipelineConfigurationModel);
}
Also used : PipelineConfigurationModel(com.redhat.devtools.intellij.tektoncd.utils.model.resources.PipelineConfigurationModel) ConditionConfigurationModel(com.redhat.devtools.intellij.tektoncd.utils.model.resources.ConditionConfigurationModel) TaskConfigurationModel(com.redhat.devtools.intellij.tektoncd.utils.model.resources.TaskConfigurationModel) PipelineConfigurationModel(com.redhat.devtools.intellij.tektoncd.utils.model.resources.PipelineConfigurationModel) Test(org.junit.Test) BaseTest(com.redhat.devtools.intellij.tektoncd.BaseTest)

Example 8 with PipelineConfigurationModel

use of com.redhat.devtools.intellij.tektoncd.utils.model.resources.PipelineConfigurationModel in project intellij-tekton by redhat-developer.

the class PipelineConfigurationModelTest method checkPipelineModelWithInputResources.

@Test
public void checkPipelineModelWithInputResources() throws IOException {
    String configuration = load("pipeline4.yaml");
    PipelineConfigurationModel model = (PipelineConfigurationModel) ConfigurationModelFactory.getModel(configuration);
    assertEquals(model.getName(), "foo");
    assertEquals(model.getNamespace(), "tekton");
    assertEquals(model.getKind(), "Pipeline");
    assertTrue(model.getParams().isEmpty());
    assertTrue(model.getInputResources().size() == 1);
    assertEquals(model.getInputResources().get(0).name(), "resource1");
    assertEquals(model.getInputResources().get(0).type(), "git");
    assertTrue(model.getOutputResources().isEmpty());
    assertTrue(model.getWorkspaces().isEmpty());
}
Also used : PipelineConfigurationModel(com.redhat.devtools.intellij.tektoncd.utils.model.resources.PipelineConfigurationModel) Test(org.junit.Test) BaseTest(com.redhat.devtools.intellij.tektoncd.BaseTest)

Example 9 with PipelineConfigurationModel

use of com.redhat.devtools.intellij.tektoncd.utils.model.resources.PipelineConfigurationModel in project intellij-tekton by redhat-developer.

the class PipelineConfigurationModelTest method checkEmptyPipelineModel.

@Test
public void checkEmptyPipelineModel() throws IOException {
    String configuration = load("pipeline1.yaml");
    PipelineConfigurationModel model = (PipelineConfigurationModel) ConfigurationModelFactory.getModel(configuration);
    assertEquals(model.getName(), "foo");
    assertEquals(model.getNamespace(), "tekton");
    assertEquals(model.getKind(), "Pipeline");
    assertTrue(model.getParams().isEmpty());
    assertTrue(model.getInputResources().isEmpty());
    assertTrue(model.getOutputResources().isEmpty());
    assertTrue(model.getWorkspaces().isEmpty());
}
Also used : PipelineConfigurationModel(com.redhat.devtools.intellij.tektoncd.utils.model.resources.PipelineConfigurationModel) Test(org.junit.Test) BaseTest(com.redhat.devtools.intellij.tektoncd.BaseTest)

Example 10 with PipelineConfigurationModel

use of com.redhat.devtools.intellij.tektoncd.utils.model.resources.PipelineConfigurationModel in project intellij-tekton by redhat-developer.

the class PipelineConfigurationModelTest method checkPipelineModelWithParams.

@Test
public void checkPipelineModelWithParams() throws IOException {
    String configuration = load("pipeline3.yaml");
    PipelineConfigurationModel model = (PipelineConfigurationModel) ConfigurationModelFactory.getModel(configuration);
    assertEquals(model.getName(), "foo");
    assertEquals(model.getNamespace(), "tekton");
    assertEquals(model.getKind(), "Pipeline");
    assertTrue(model.getParams().size() == 1);
    assertEquals(model.getParams().get(0).name(), "param1");
    assertTrue(model.getInputResources().isEmpty());
    assertTrue(model.getOutputResources().isEmpty());
    assertTrue(model.getWorkspaces().isEmpty());
}
Also used : PipelineConfigurationModel(com.redhat.devtools.intellij.tektoncd.utils.model.resources.PipelineConfigurationModel) Test(org.junit.Test) BaseTest(com.redhat.devtools.intellij.tektoncd.BaseTest)

Aggregations

PipelineConfigurationModel (com.redhat.devtools.intellij.tektoncd.utils.model.resources.PipelineConfigurationModel)11 BaseTest (com.redhat.devtools.intellij.tektoncd.BaseTest)6 Test (org.junit.Test)6 ArrayList (java.util.ArrayList)5 ConfigurationModel (com.redhat.devtools.intellij.tektoncd.utils.model.ConfigurationModel)4 InspectionManager (com.intellij.codeInspection.InspectionManager)3 ProblemDescriptor (com.intellij.codeInspection.ProblemDescriptor)3 ProblemHighlightType (com.intellij.codeInspection.ProblemHighlightType)3 PsiElement (com.intellij.psi.PsiElement)3 PsiFile (com.intellij.psi.PsiFile)3 Collections (java.util.Collections)3 List (java.util.List)3 Pattern (java.util.regex.Pattern)3 NotNull (org.jetbrains.annotations.NotNull)3 Nullable (org.jetbrains.annotations.Nullable)3 LookupElementBuilder (com.intellij.codeInsight.lookup.LookupElementBuilder)2 ASTNode (com.intellij.lang.ASTNode)2 StringHelper (com.redhat.devtools.intellij.common.utils.StringHelper)2 TaskConfigurationModel (com.redhat.devtools.intellij.tektoncd.utils.model.resources.TaskConfigurationModel)2 LocalQuickFix (com.intellij.codeInspection.LocalQuickFix)1