Don't check for unknown resource errors in input_mapping
This commit is contained in:
@@ -17,6 +17,7 @@ package org.springframework.ide.vscode.commons.yaml.schema;
|
||||
*
|
||||
* @author Kris De Volder
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface SchemaContextAware<T> {
|
||||
T withContext(DynamicSchemaContext dc);
|
||||
|
||||
|
||||
@@ -44,6 +44,7 @@ public class ConcourseDefinitionFinder extends SimpleDefinitionFinder<ConcourseL
|
||||
this.models = models;
|
||||
this.astTypes = models.getAstTypeCache();
|
||||
findByPath(schema.t_resource_name, ConcourseModel.RESOURCE_NAMES_PATH);
|
||||
findByPath(schema.t_maybe_resource_name, ConcourseModel.RESOURCE_NAMES_PATH);
|
||||
findByPath(schema.t_job_name, ConcourseModel.JOB_NAMES_PATH);
|
||||
findByPath(schema.t_resource_type_name, ConcourseModel.RESOURCE_TYPE_NAMES_PATH);
|
||||
}
|
||||
|
||||
@@ -12,7 +12,9 @@ package org.springframework.ide.vscode.concourse;
|
||||
|
||||
import java.time.ZoneId;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.springframework.ide.vscode.commons.languageserver.reconcile.IProblemCollector;
|
||||
@@ -30,6 +32,7 @@ import org.springframework.ide.vscode.commons.yaml.path.YamlPathSegment;
|
||||
import org.springframework.ide.vscode.commons.yaml.reconcile.YamlSchemaProblems;
|
||||
import org.springframework.ide.vscode.commons.yaml.schema.BasicYValueHint;
|
||||
import org.springframework.ide.vscode.commons.yaml.schema.DynamicSchemaContext;
|
||||
import org.springframework.ide.vscode.commons.yaml.schema.SchemaContextAware;
|
||||
import org.springframework.ide.vscode.commons.yaml.schema.YType;
|
||||
import org.springframework.ide.vscode.commons.yaml.schema.YTypeFactory;
|
||||
import org.springframework.ide.vscode.commons.yaml.schema.YTypeFactory.AbstractType;
|
||||
@@ -100,6 +103,7 @@ public class PipelineYmlSchema implements YamlSchema {
|
||||
.parseWith(ValueParsers.integerAtLeast(1));
|
||||
|
||||
public final AbstractType t_resource_name;
|
||||
public final YAtomicType t_maybe_resource_name;
|
||||
public final AbstractType t_job_name;
|
||||
public final YAtomicType t_resource_type_name;
|
||||
public final YType t_mime_type = f.yatomic("MimeType")
|
||||
@@ -151,6 +155,7 @@ public class PipelineYmlSchema implements YamlSchema {
|
||||
|
||||
private List<YType> definitionTypes = new ArrayList<>();
|
||||
|
||||
|
||||
public PipelineYmlSchema(ConcourseModel models) {
|
||||
this.models = models;
|
||||
models.setResourceTypeRegistry(resourceTypes);
|
||||
@@ -179,6 +184,14 @@ public class PipelineYmlSchema implements YamlSchema {
|
||||
return (models.getResourceNames(dc));
|
||||
}
|
||||
);
|
||||
t_maybe_resource_name = f.yatomic("ResourceName | TaskOutput");
|
||||
t_maybe_resource_name.addHintProvider((DynamicSchemaContext dc) -> {
|
||||
//Putting the Callable into a local variable is strange, but the compiler doesn't like it if
|
||||
// we return it directly. Too much complexity for Java type-inference?
|
||||
Callable<Collection<YValueHint>> callable = () -> YTypeFactory.hints(models.getResourceNames(dc));
|
||||
return callable;
|
||||
});
|
||||
t_maybe_resource_name.parseWith(ValueParsers.NE_STRING);
|
||||
|
||||
t_job_name = f.yenum("Job Name",
|
||||
(parseString, validValues) -> {
|
||||
@@ -311,7 +324,7 @@ public class PipelineYmlSchema implements YamlSchema {
|
||||
addProp(taskStep, "privileged", t_boolean);
|
||||
addProp(taskStep, "params", t_params);
|
||||
addProp(taskStep, "image", t_resource_name);
|
||||
addProp(taskStep, "input_mapping", f.ymap(t_ne_string, t_resource_name));
|
||||
addProp(taskStep, "input_mapping", f.ymap(t_ne_string, t_maybe_resource_name));
|
||||
addProp(taskStep, "output_mapping", t_string_params);
|
||||
taskStep.requireOneOf("config", "file");
|
||||
|
||||
|
||||
@@ -16,5 +16,5 @@ import org.springframework.ide.vscode.commons.languageserver.reconcile.ProblemTy
|
||||
import static org.springframework.ide.vscode.commons.yaml.reconcile.YamlSchemaProblems.*;
|
||||
|
||||
public class PipelineYmlSchemaProblems {
|
||||
protected static final ProblemType UNUSED_RESOURCE = problemType("PipelineYamlUnusedResource", ProblemSeverity.WARNING);
|
||||
protected static final ProblemType UNUSED_RESOURCE = problemType("PipelineYamlUnusedResource", ProblemSeverity.ERROR);
|
||||
}
|
||||
|
||||
@@ -585,14 +585,14 @@ public class ConcourseEditorTest {
|
||||
editor.assertProblems(
|
||||
"bogus-get|resource does not exist",
|
||||
"bogus-image|resource does not exist",
|
||||
"bogus-input|resource does not exist",
|
||||
// "bogus-input|resource does not exist", //Not checked anymore. See: https://www.pivotaltracker.com/story/show/145024233
|
||||
"bogus-put|resource does not exist"
|
||||
);
|
||||
|
||||
editor.assertProblems(
|
||||
"bogus-get|[sts4]",
|
||||
"bogus-image|[sts4]",
|
||||
"bogus-input|[sts4]",
|
||||
// "bogus-input|[sts4]", //Not checked anymore. See: https://www.pivotaltracker.com/story/show/145024233
|
||||
"bogus-put|[sts4]"
|
||||
);
|
||||
}
|
||||
@@ -744,6 +744,24 @@ public class ConcourseEditorTest {
|
||||
, // =>
|
||||
"repo-a<*>", "repo-b<*>"
|
||||
);
|
||||
|
||||
assertContextualCompletions(
|
||||
"resources:\n" +
|
||||
"- name: sts4\n" +
|
||||
"- name: repo-a\n" +
|
||||
"- name: repo-b\n" +
|
||||
"jobs:\n" +
|
||||
"- name: job1\n" +
|
||||
" plan:\n" +
|
||||
" - task: do-it\n" +
|
||||
" input_mapping:\n" +
|
||||
" remapped: <*>\n"
|
||||
, ////////////////////
|
||||
"<*>"
|
||||
, // =>
|
||||
"repo-a<*>", "repo-b<*>", "sts4<*>"
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -3695,7 +3713,7 @@ public class ConcourseEditorTest {
|
||||
" - get: version\n"
|
||||
);
|
||||
Diagnostic p = editor.assertProblems("source-repo|Unused 'Resource'").get(0);
|
||||
assertEquals(DiagnosticSeverity.Warning, p.getSeverity());
|
||||
assertEquals(DiagnosticSeverity.Error, p.getSeverity());
|
||||
|
||||
editor = harness.newEditor(
|
||||
"resources:\n" +
|
||||
|
||||
11
vscode-extensions/.project
Normal file
11
vscode-extensions/.project
Normal file
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>vscode-extensions</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
Reference in New Issue
Block a user