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 93c8882b9..66047fbe7 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 @@ -621,7 +621,31 @@ public class PipelineYmlSchema implements YamlSchema { //put params deliberately left empty resourceTypes.def("time", source, get, put); + } + //cloudfoundry: + { + YAtomicType t_cf_api_url = f.yatomic("CFApiUrl"); + t_cf_api_url.addHints("https://api.run.pivotal.io"); + t_cf_api_url.parseWith(ValueParsers.NE_STRING); + AbstractType source = f.ybean("CloudFoundrySource"); + addProp(source, "api", t_cf_api_url).isRequired(true); + addProp(source, "username", t_ne_string).isRequired(true); + addProp(source, "password", t_ne_string).isRequired(true); + addProp(source, "organization", t_ne_string).isRequired(true); + addProp(source, "space", t_ne_string).isRequired(true); + addProp(source, "skip_cert_check", t_ne_string); + + AbstractType get = f.ybean("CloudFoundryGetParams"); + //get params deliberately left empty + + AbstractType put = f.ybean("CloudFoundryPutParams"); + addProp(put, "manifest", t_ne_string).isRequired(true); + addProp(put, "path", t_ne_string); + addProp(put, "current_app_name", t_ne_string); + addProp(put, "environment_variables", t_string_params); + + resourceTypes.def("cf", source, get, put); } } diff --git a/headless-services/concourse-language-server/src/main/resources/desc/CloudFoundryPutParams/current_app_name.md b/headless-services/concourse-language-server/src/main/resources/desc/CloudFoundryPutParams/current_app_name.md new file mode 100644 index 000000000..4793ea57d --- /dev/null +++ b/headless-services/concourse-language-server/src/main/resources/desc/CloudFoundryPutParams/current_app_name.md @@ -0,0 +1 @@ +*Optional*. This should be the name of the application that this will re-deploy over. If this is set the resource will perform a zero-downtime deploy. \ No newline at end of file diff --git a/headless-services/concourse-language-server/src/main/resources/desc/CloudFoundryPutParams/environment_variables.md b/headless-services/concourse-language-server/src/main/resources/desc/CloudFoundryPutParams/environment_variables.md new file mode 100644 index 000000000..5850e1827 --- /dev/null +++ b/headless-services/concourse-language-server/src/main/resources/desc/CloudFoundryPutParams/environment_variables.md @@ -0,0 +1 @@ +*Optional*. Environment variables to set in deployed app's environment. \ No newline at end of file diff --git a/headless-services/concourse-language-server/src/main/resources/desc/CloudFoundryPutParams/manifest.md b/headless-services/concourse-language-server/src/main/resources/desc/CloudFoundryPutParams/manifest.md new file mode 100644 index 000000000..268575d02 --- /dev/null +++ b/headless-services/concourse-language-server/src/main/resources/desc/CloudFoundryPutParams/manifest.md @@ -0,0 +1 @@ +*Required*. Path to a application manifest file. \ No newline at end of file diff --git a/headless-services/concourse-language-server/src/main/resources/desc/CloudFoundryPutParams/path.md b/headless-services/concourse-language-server/src/main/resources/desc/CloudFoundryPutParams/path.md new file mode 100644 index 000000000..4375f4dd7 --- /dev/null +++ b/headless-services/concourse-language-server/src/main/resources/desc/CloudFoundryPutParams/path.md @@ -0,0 +1 @@ +*Optional*. Path to the application to push. If this isn't set then it will be read from the manifest instead. \ No newline at end of file diff --git a/headless-services/concourse-language-server/src/main/resources/desc/CloudFoundrySource/api.md b/headless-services/concourse-language-server/src/main/resources/desc/CloudFoundrySource/api.md new file mode 100644 index 000000000..fc29bd703 --- /dev/null +++ b/headless-services/concourse-language-server/src/main/resources/desc/CloudFoundrySource/api.md @@ -0,0 +1,2 @@ +*Required*. The address of the Cloud Controller in the Cloud Foundry deployment. +username \ No newline at end of file diff --git a/headless-services/concourse-language-server/src/main/resources/desc/CloudFoundrySource/organization.md b/headless-services/concourse-language-server/src/main/resources/desc/CloudFoundrySource/organization.md new file mode 100644 index 000000000..d1c932aa3 --- /dev/null +++ b/headless-services/concourse-language-server/src/main/resources/desc/CloudFoundrySource/organization.md @@ -0,0 +1 @@ +*Required*. The organization to push the application to. \ No newline at end of file diff --git a/headless-services/concourse-language-server/src/main/resources/desc/CloudFoundrySource/password.md b/headless-services/concourse-language-server/src/main/resources/desc/CloudFoundrySource/password.md new file mode 100644 index 000000000..a449bd876 --- /dev/null +++ b/headless-services/concourse-language-server/src/main/resources/desc/CloudFoundrySource/password.md @@ -0,0 +1 @@ +*Required*. The password used to authenticate. \ No newline at end of file diff --git a/headless-services/concourse-language-server/src/main/resources/desc/CloudFoundrySource/skip_cert_check.md b/headless-services/concourse-language-server/src/main/resources/desc/CloudFoundrySource/skip_cert_check.md new file mode 100644 index 000000000..3a246d2c4 --- /dev/null +++ b/headless-services/concourse-language-server/src/main/resources/desc/CloudFoundrySource/skip_cert_check.md @@ -0,0 +1 @@ +*Optional*. Check the validity of the CF SSL cert. Defaults to `false`. \ No newline at end of file diff --git a/headless-services/concourse-language-server/src/main/resources/desc/CloudFoundrySource/space.md b/headless-services/concourse-language-server/src/main/resources/desc/CloudFoundrySource/space.md new file mode 100644 index 000000000..43c82fbb5 --- /dev/null +++ b/headless-services/concourse-language-server/src/main/resources/desc/CloudFoundrySource/space.md @@ -0,0 +1 @@ +*Required*. The space to push the application to. \ No newline at end of file diff --git a/headless-services/concourse-language-server/src/main/resources/desc/CloudFoundrySource/username.md b/headless-services/concourse-language-server/src/main/resources/desc/CloudFoundrySource/username.md new file mode 100644 index 000000000..714a2d9fd --- /dev/null +++ b/headless-services/concourse-language-server/src/main/resources/desc/CloudFoundrySource/username.md @@ -0,0 +1 @@ +*Required*. The username used to authenticate. \ 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 942e05caf..7ea842d68 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 @@ -3977,6 +3977,90 @@ public class ConcourseEditorTest { editor.assertProblems(/*NONE*/); } + @Test public void cfResourceSourceCompletions() throws Exception { + Editor editor = harness.newEditor( + "resources:\n" + + "- name: pws\n" + + " type: cf\n" + + " source:\n" + + " <*>" + ); + editor.assertContextualCompletions(PLAIN_COMPLETION, "<*>", + //Snippet: + "api: $1\n" + + " username: $2\n" + + " password: $3\n" + + " organization: $4\n" + + " space: $5<*>" + , // non-snippet: + "api: <*>", + "organization: <*>", + "password: <*>", + "space: <*>", + "username: <*>" + ); + + editor = harness.newEditor( + "resources:\n" + + "- name: pws\n" + + " type: cf\n" + + " source:\n" + + " api: {{cf_api}}\n" + + " username: {{cf_user}}\n" + + " password: {{cf_password}}\n" + + " organization: {{cf_org}}\n" + + " space: {{cf_space}}\n" + + " <*>" + ); + editor.assertContextualCompletions(PLAIN_COMPLETION, "<*>", + "skip_cert_check: <*>" + ); + } + + @Test public void cfResourceSourceHovers() throws Exception { + Editor editor = harness.newEditor( + "resources:\n" + + "- name: pws\n" + + " type: cf\n" + + " source:\n" + + " api: {{cf_api}}\n" + + " username: {{cf_user}}\n" + + " password: {{cf_password}}\n" + + " organization: {{cf_org}}\n" + + " space: {{cf_space}}\n" + + " skip_cert_check: true<*>" + ); + editor.assertHoverContains("api", "address of the Cloud Controller"); + editor.assertHoverContains("username", "username used to authenticate"); + editor.assertHoverContains("password", "password used to authenticate"); + editor.assertHoverContains("organization", "organization to push"); + editor.assertHoverContains("space", "space to push"); + editor.assertHoverContains("skip_cert_check", "Check the validity of the CF SSL cert"); + } + + @Test public void cfPutParamsHovers() throws Exception { + Editor editor = harness.newEditor( + "resources:\n" + + "- name: pws\n" + + " type: cf\n" + + "jobs:\n" + + "- name: deploy-stuff\n" + + " plan:\n" + + " - put: pws\n" + + " params:\n" + + " manifest: repo/manifest.yml\n" + + " path: out/*.jar\n" + + " current_app_name: the-name\n" + + " environment_variables:\n" + + " key: value\n" + + " key2: value2\n" + ); + editor.assertHoverContains("manifest", "Path to a application manifest file"); + editor.assertHoverContains("path", "Path to the application to push"); + editor.assertHoverContains("current_app_name", "zero-downtime deploy"); + editor.assertHoverContains("environment_variables", "Environment variables"); + } + ////////////////////////////////////////////////////////////////////////////// private void assertContextualCompletions(String conText, String textBefore, String... textAfter) throws Exception {