From 9256934ce8941d5cf0f2fa0b701b480b6553f780 Mon Sep 17 00:00:00 2001 From: Kris De Volder Date: Thu, 31 Oct 2019 15:39:39 -0700 Subject: [PATCH] Add support for `check_every` in concourse 'ResourceType' and other... missing ResourceType attributes See: https://github.com/spring-projects/sts4/issues/382 --- .../vscode/concourse/PipelineYmlSchema.java | 4 ++ .../desc/ResourceType/check_every.md | 3 ++ .../main/resources/desc/ResourceType/tags.md | 3 ++ .../ResourceType/unique_version_history.md | 4 ++ .../vscode/concourse/ConcourseEditorTest.java | 46 ++++++++++++++++++- 5 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 headless-services/concourse-language-server/src/main/resources/desc/ResourceType/check_every.md create mode 100644 headless-services/concourse-language-server/src/main/resources/desc/ResourceType/tags.md create mode 100644 headless-services/concourse-language-server/src/main/resources/desc/ResourceType/unique_version_history.md diff --git a/headless-services/concourse-language-server/src/main/java/org/springframework/ide/vscode/concourse/PipelineYmlSchema.java b/headless-services/concourse-language-server/src/main/java/org/springframework/ide/vscode/concourse/PipelineYmlSchema.java index afdfcb584..187ecac01 100644 --- a/headless-services/concourse-language-server/src/main/java/org/springframework/ide/vscode/concourse/PipelineYmlSchema.java +++ b/headless-services/concourse-language-server/src/main/java/org/springframework/ide/vscode/concourse/PipelineYmlSchema.java @@ -425,6 +425,10 @@ public class PipelineYmlSchema implements YamlSchema { addProp(resourceType, "type", t_resource_type_name).isRequired(true); addProp(resourceType, "source", resourceSource); addProp(resourceType, "privileged", t_boolean); + addProp(resourceType, "params", t_params); + addProp(resourceType, "check_every", t_duration); + addProp(resourceType, "tags", t_strings); + addProp(resourceType, "unique_version_history", t_boolean); YType t_group_name_def= f.yatomic("Group Name") .parseWith(ValueParsers.NE_STRING); diff --git a/headless-services/concourse-language-server/src/main/resources/desc/ResourceType/check_every.md b/headless-services/concourse-language-server/src/main/resources/desc/ResourceType/check_every.md new file mode 100644 index 000000000..2fbd20af4 --- /dev/null +++ b/headless-services/concourse-language-server/src/main/resources/desc/ResourceType/check_every.md @@ -0,0 +1,3 @@ +*Optional*. *Default* `1m`. The interval on which to check for new versions +of the resource type. Acceptable interval options are defined by the +[time.ParseDuration function](https://golang.org/pkg/time/#ParseDuration). diff --git a/headless-services/concourse-language-server/src/main/resources/desc/ResourceType/tags.md b/headless-services/concourse-language-server/src/main/resources/desc/ResourceType/tags.md new file mode 100644 index 000000000..286bbe708 --- /dev/null +++ b/headless-services/concourse-language-server/src/main/resources/desc/ResourceType/tags.md @@ -0,0 +1,3 @@ +*Optional*. A list of tags to determine which workers the checks will be performed on. You'll want to specify this if +the source is internal to a worker's network, for example. See also [tags](https://concourse-ci.org/tags-step-modifier.html) step modifier. + diff --git a/headless-services/concourse-language-server/src/main/resources/desc/ResourceType/unique_version_history.md b/headless-services/concourse-language-server/src/main/resources/desc/ResourceType/unique_version_history.md new file mode 100644 index 000000000..c22ff2b68 --- /dev/null +++ b/headless-services/concourse-language-server/src/main/resources/desc/ResourceType/unique_version_history.md @@ -0,0 +1,4 @@ +*Optional*. *Default* `false`. Only relevant when [Global Resources](https://concourse-ci.org/global-resources.html) is enabled. When set to `true`, +resources using this resource type will have a version history that is unique to the resource, rather than sharing a global version history. + + diff --git a/headless-services/concourse-language-server/src/test/java/org/springframework/ide/vscode/concourse/ConcourseEditorTest.java b/headless-services/concourse-language-server/src/test/java/org/springframework/ide/vscode/concourse/ConcourseEditorTest.java index 3200b0edb..06b78771a 100644 --- a/headless-services/concourse-language-server/src/test/java/org/springframework/ide/vscode/concourse/ConcourseEditorTest.java +++ b/headless-services/concourse-language-server/src/test/java/org/springframework/ide/vscode/concourse/ConcourseEditorTest.java @@ -1759,12 +1759,52 @@ public class ConcourseEditorTest { ); } + @Test + public void resourceTypeAttributeReconcile() throws Exception { + //Example from https://github.com/spring-projects/sts4/issues/382 + Editor editor = harness.newEditor( + "resource_types:\n" + + "\n" + + "- name: cogito\n" + + " type: registry-image\n" + + " check_every: 24h\n" + + " source:\n" + + " repository: ((docker-registry))/cogito" + ); + editor.assertProblems(/*none*/); + + //More elaborate example + editor = harness.newEditor( + "resource_types:\n" + + "- name: cogito\n" + + " type: registry-image\n" + + " check_every: bad-duration\n" + + " privileged: is-priviliged\n" + + " params:\n" + + " foo: bar\n"+ + " tags: tags-list\n" + + " unique_version_history: is-unique-hist\n" + + " source:\n" + + " repository: ((docker-registry))/cogito" + ); + editor.assertProblems( + "bad-duration|Duration", + "is-priviliged|boolean", + "tags-list|Sequence", + "is-unique-hist|boolean" + ); + } + @Test public void resourceTypeAttributeHovers() throws Exception { Editor editor = harness.newEditor( "resource_types:\n" + "- name: s3-multi\n" + " type: docker-image\n" + + " check_every: bad-duration\n" + + " privileged: is-priviliged\n" + + " tags: tags-list\n" + + " unique_version_history: is-unique-hist\n" + " source:\n" + " repository: kdvolder/s3-resource-simple\n" ); @@ -1772,6 +1812,10 @@ public class ConcourseEditorTest { editor.assertHoverContains("name", "This name will be referenced by `resources` defined within the same pipeline"); editor.assertHoverContains("type", 2, "used to provide the resource type's container image"); editor.assertHoverContains("source", 2, "The location of the resource type's resource"); + editor.assertHoverContains("privileged", "containers will be run with full capabilities"); + editor.assertHoverContains("check_every", "interval on which to check for new versions"); + editor.assertHoverContains("tags", "list of tags to determine which workers"); + editor.assertHoverContains("unique_version_history", "resource type will have a version history that is unique to the resource"); } @Test @@ -1789,7 +1833,7 @@ public class ConcourseEditorTest { editor.assertHoverContains("name", "The name of the resource"); editor.assertHoverContains("type", "The type of the resource. Each worker advertises"); - editor.assertHoverContains("icon", "name of a [Material Design Icon]"); + editor.assertHoverContains("icon", "name of a [Material Design Icon]"); editor.assertHoverContains("source", 2, "The location of the resource"); editor.assertHoverContains("webhook_token", "web hooks can be sent to trigger an immediate *check* of the resource"); editor.assertHoverContains("check_every", "The interval on which to check for new versions");