From f825c2e7974c4b602000a2e1746860d0ecdb3576 Mon Sep 17 00:00:00 2001 From: Kris De Volder Date: Wed, 5 May 2021 10:46:10 -0700 Subject: [PATCH] Add `old_name` property to Resource schema See: https://github.com/spring-projects/sts4/issues/633 --- .../vscode/concourse/PipelineYmlSchema.java | 1 + .../main/resources/desc/Resource/old_name.md | 20 +++++++++++++++++++ .../vscode/concourse/ConcourseEditorTest.java | 4 ++++ 3 files changed, 25 insertions(+) create mode 100644 headless-services/concourse-language-server/src/main/resources/desc/Resource/old_name.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 a16be166e..d9e637ee6 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 @@ -238,6 +238,7 @@ public class PipelineYmlSchema implements YamlSchema { addProp(t_resource, "tags", t_strings); addProp(t_resource, "webhook_token", t_ne_string); addProp(t_resource, "icon", t_ne_string); + addProp(t_resource, "old_name", t_ne_string); AbstractType t_image_resource = f.ybean("ImageResource"); { diff --git a/headless-services/concourse-language-server/src/main/resources/desc/Resource/old_name.md b/headless-services/concourse-language-server/src/main/resources/desc/Resource/old_name.md new file mode 100644 index 000000000..2558dd6f0 --- /dev/null +++ b/headless-services/concourse-language-server/src/main/resources/desc/Resource/old_name.md @@ -0,0 +1,20 @@ +*Optional* The old name of the resource. If configured, the history of the old resource will be inherited to the new one. Once the pipeline is set, this field can be removed as the history has been transferred. + +This can be used to rename a resource without losing its history, like so: + +``` +resources: +- name: new-name + old_name: current-name + type: git + source: uri: "https://github.com/vito/booklit" + ``` + +After the pipeline is set, the resource was successfully renamed, so the `old_name` field can be removed from the resource: + +``` +resources: +- name: new-name + type: git + source: uri: "https://github.com/vito/booklit" +``` \ No newline at end of file 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 4972fbb4f..8d906ae64 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 @@ -1906,6 +1906,7 @@ public class ConcourseEditorTest { "- name: s3-multi\n" + " type: docker-image\n" + " check_every: bad-duration\n" + + " old_name: was-renamed\n" + " privileged: is-priviliged\n" + " tags: tags-list\n" + " unique_version_history: is-unique-hist\n" + @@ -1928,6 +1929,7 @@ public class ConcourseEditorTest { "resources:\n" + "- name: sts4\n" + " type: git\n" + + " old_name: was-renamed\n" + " icon: foo\n" + " check_every: 5m\n" + " webhook_token: bladayadayaaa\n" + @@ -1937,6 +1939,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("old_name", "history of the old resource will be inherited"); 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"); @@ -4024,6 +4027,7 @@ public class ConcourseEditorTest { //For the 'exact' context: "check_every", "icon", + "old_name", "tags", "webhook_token", //"name", exists