From c8e5c6e3c56b77ddbaca449a19e586edf72875bd Mon Sep 17 00:00:00 2001 From: Kris De Volder Date: Thu, 26 Jan 2017 18:31:41 -0800 Subject: [PATCH] Support (CA/hover/reconcile) for task.run sub-properties --- .../vscode/concourse/PipelineYmlSchema.java | 7 ++- .../src/main/resources/desc/Command/args.md | 1 + .../src/main/resources/desc/Command/dir.md | 1 + .../src/main/resources/desc/Command/path.md | 1 + .../src/main/resources/desc/Command/user.md | 1 + .../vscode/concourse/ConcourseEditorTest.java | 46 +++++++++++++++++++ 6 files changed, 55 insertions(+), 2 deletions(-) create mode 100644 vscode-extensions/vscode-concourse/src/main/resources/desc/Command/args.md create mode 100644 vscode-extensions/vscode-concourse/src/main/resources/desc/Command/dir.md create mode 100644 vscode-extensions/vscode-concourse/src/main/resources/desc/Command/path.md create mode 100644 vscode-extensions/vscode-concourse/src/main/resources/desc/Command/user.md diff --git a/vscode-extensions/vscode-concourse/src/main/java/org/springframework/ide/vscode/concourse/PipelineYmlSchema.java b/vscode-extensions/vscode-concourse/src/main/java/org/springframework/ide/vscode/concourse/PipelineYmlSchema.java index b0527ced4..cc7ced11a 100644 --- a/vscode-extensions/vscode-concourse/src/main/java/org/springframework/ide/vscode/concourse/PipelineYmlSchema.java +++ b/vscode-extensions/vscode-concourse/src/main/java/org/springframework/ide/vscode/concourse/PipelineYmlSchema.java @@ -173,8 +173,11 @@ public class PipelineYmlSchema implements YamlSchema { f.yprop("path", t_ne_string) ); - YType t_command = f.yany("Command"); - //TODO: add structure for command. + YBeanType t_command = f.ybean("Command"); + addProp(t_command, "path", t_ne_string).isRequired(true); + addProp(t_command, "args", t_strings); + addProp(t_command, "dir", t_ne_string); + addProp(t_command, "user", t_string); task = f.ybean("TaskConfig"); addProp(task, "platform", t_platform).isRequired(true); diff --git a/vscode-extensions/vscode-concourse/src/main/resources/desc/Command/args.md b/vscode-extensions/vscode-concourse/src/main/resources/desc/Command/args.md new file mode 100644 index 000000000..f85023400 --- /dev/null +++ b/vscode-extensions/vscode-concourse/src/main/resources/desc/Command/args.md @@ -0,0 +1 @@ +*Optional.* Arguments to pass to the command. Note that when executed with `fly`, any arguments passed to `fly` are appended to this array. \ No newline at end of file diff --git a/vscode-extensions/vscode-concourse/src/main/resources/desc/Command/dir.md b/vscode-extensions/vscode-concourse/src/main/resources/desc/Command/dir.md new file mode 100644 index 000000000..4bba020e5 --- /dev/null +++ b/vscode-extensions/vscode-concourse/src/main/resources/desc/Command/dir.md @@ -0,0 +1 @@ +*Optional.* A directory, relative to the initial working directory, to set as the working directory when running the script. \ No newline at end of file diff --git a/vscode-extensions/vscode-concourse/src/main/resources/desc/Command/path.md b/vscode-extensions/vscode-concourse/src/main/resources/desc/Command/path.md new file mode 100644 index 000000000..c78f746cd --- /dev/null +++ b/vscode-extensions/vscode-concourse/src/main/resources/desc/Command/path.md @@ -0,0 +1 @@ +*Required.* The command to execute, relative to the task's working directory. For a script living in a resource's repo, you must specify the full path to the resource, i.e. `my-resource/scripts/test`. \ No newline at end of file diff --git a/vscode-extensions/vscode-concourse/src/main/resources/desc/Command/user.md b/vscode-extensions/vscode-concourse/src/main/resources/desc/Command/user.md new file mode 100644 index 000000000..f33af8a90 --- /dev/null +++ b/vscode-extensions/vscode-concourse/src/main/resources/desc/Command/user.md @@ -0,0 +1 @@ +*Optional.* Explicitly set the user to run as. If not specified, this defaults to the user configured by the task's image. If not specified there, it's up to the Garden backend, and may be e.g. `root` on Linux. \ No newline at end of file diff --git a/vscode-extensions/vscode-concourse/src/test/java/org/springframework/ide/vscode/concourse/ConcourseEditorTest.java b/vscode-extensions/vscode-concourse/src/test/java/org/springframework/ide/vscode/concourse/ConcourseEditorTest.java index d38b0d79b..14fe089df 100644 --- a/vscode-extensions/vscode-concourse/src/test/java/org/springframework/ide/vscode/concourse/ConcourseEditorTest.java +++ b/vscode-extensions/vscode-concourse/src/test/java/org/springframework/ide/vscode/concourse/ConcourseEditorTest.java @@ -1580,6 +1580,52 @@ public class ConcourseEditorTest { ); } + @Test public void taskRunPropertiesValidationAndHovers() throws Exception { + Editor editor; + + editor = harness.newEditor(LanguageIds.CONCOURSE_TASK, + "inputs:\n" + + "- name: sts4\n" + + "outputs:\n" + + "- name: vsix-files\n" + + "platform: linux\n" + + "image_resource:\n" + + " type: docker-image\n" + + " source:\n" + + " repository: kdvolder/sts4-build-env\n" + + "run:\n" + + " path: sts4/concourse/tasks/build-vscode-extensions.sh\n" + + " args: the-args\n" + + " user: admin\n" + + " dir: the-dir\n" + + " bogus: bad\n" + ); + editor.assertProblems( + "the-args|Expecting a 'Sequence'", + "bogus|Unknown property" + ); + + editor.assertHoverContains("path", "The command to execute, relative to the task's working directory"); + editor.assertHoverContains("args", "Arguments to pass to the command"); + editor.assertHoverContains("dir", "A directory, relative to the initial working directory, to set as the working directory"); + editor.assertHoverContains("user", "Explicitly set the user to run as"); + + editor = harness.newEditor(LanguageIds.CONCOURSE_TASK, + "inputs:\n" + + "- name: sts4\n" + + "outputs:\n" + + "- name: vsix-files\n" + + "platform: linux\n" + + "image_resource:\n" + + " type: docker-image\n" + + " source:\n" + + " repository: kdvolder/sts4-build-env\n" + + "run:\n" + + " user: admin\n" + ); + editor.assertProblems("user: admin|'path' is required"); + } + ////////////////////////////////////////////////////////////////////////////// private void assertContextualCompletions(String conText, String textBefore, String... textAfter) throws Exception {