Define basic structure for task.yml files

This commit is contained in:
Kris De Volder
2017-01-26 12:20:18 -08:00
parent df4929f93a
commit ae3218ba66
3 changed files with 43 additions and 9 deletions

View File

@@ -11,6 +11,7 @@
package org.springframework.ide.vscode.commons.util;
import java.util.Collection;
import java.util.TreeSet;
import java.util.concurrent.Callable;
import javax.inject.Provider;
@@ -68,7 +69,7 @@ public class EnumValueParser implements ValueParser {
}
protected String createErrorMessage(String parseString, Collection<String> values) {
return "'" + parseString + "' is not valid for Enum '" + typeName + "'. Valid values are: " + values;
return "'" + parseString + "' is an unknown '" + typeName + "'. Valid values are: " + new TreeSet<>(values);
}
protected Exception errorOnParse(String message) {

View File

@@ -32,6 +32,7 @@ import org.springframework.ide.vscode.commons.yaml.schema.YTypeFactory.YTypedPro
import reactor.core.publisher.Flux;
import org.springframework.ide.vscode.commons.yaml.schema.YTypeUtil;
import org.springframework.ide.vscode.commons.yaml.schema.YTypedProperty;
import org.springframework.ide.vscode.commons.yaml.schema.YValueHint;
import org.springframework.ide.vscode.commons.yaml.schema.YamlSchema;
@@ -238,9 +239,31 @@ public class PipelineYmlSchema implements YamlSchema {
addProp(TOPLEVEL_TYPE, "resource_types", f.yseq(resourceType));
addProp(TOPLEVEL_TYPE, "groups", f.yseq(group));
task = f.ybean("TaskConfig");
YBeanType t_image_resource = f.ybean("ImageResource");
for (YTypedProperty p : resource.getProperties()) {
if (!"name".equals(p.getName())) {
t_image_resource.addProperty(p);
}
}
YType t_platform = f.yenum("Platform", "windows", "linux", "darwin");
addProp(task, "platform", t_platform);
YType t_name_and_path = f.ybean("NameAndPath" ,
f.yprop("name", t_ne_string).isRequired(true),
f.yprop("path", t_ne_string)
);
YType t_command = f.yany("Command");
//TODO: add structure for command.
task = f.ybean("TaskConfig");
addProp(task, "platform", t_platform).isRequired(true);
addProp(task, "image_resource", t_image_resource);
addProp(task, "image", t_ne_string);
addProp(task, "inputs", f.yseq(t_name_and_path));
addProp(task, "outputs", f.yseq(t_name_and_path));
addProp(task, "run", t_command).isRequired(true);
addProp(task, "params", t_string_params);
initializeDefaultResourceTypes();
}

View File

@@ -1451,13 +1451,20 @@ public class ConcourseEditorTest {
, // ===>
expectedCompletions
);
}
@Test public void reconcileTaskFileToplevelProperties() throws Exception {
Editor editor = harness.newEditor(LanguageIds.CONCOURSE_TASK,
Editor editor;
editor = harness.newEditor(LanguageIds.CONCOURSE_TASK,
"image: some-image"
);
editor.assertProblems("image: some-image|[platform, run] are required");
editor = harness.newEditor(LanguageIds.CONCOURSE_TASK,
"platform: a-platform\n" +
"image_resource:\n" +
" name: should-not-be-here\n" +
" type: docker-image\n" +
" source:\n" +
" bogus-source-prop: bad\n" +
@@ -1469,13 +1476,16 @@ public class ConcourseEditorTest {
"outputs:\n" +
"- path: path/to/output\n" +
"run:\n" +
" path: my-app/scripts/test"
" path: my-app/scripts/test\n" +
"params: the-params\n"
);
editor.assertProblems(
"a-platform|blah",
"bogus-source-prop|Unkown property",
"a-platform|unknown 'Platform'",
"name|Unknown property",
"bogus-source-prop|Unknown property",
"path: path/to/input|'name' is required",
"path: path/to/output|'name' is required"
"path: path/to/output|'name' is required",
"the-params|Expecting a 'Map'"
);
}