Add support for CF resource type to concourse editor
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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.
|
||||
@@ -0,0 +1 @@
|
||||
*Optional*. Environment variables to set in deployed app's environment.
|
||||
@@ -0,0 +1 @@
|
||||
*Required*. Path to a application manifest file.
|
||||
@@ -0,0 +1 @@
|
||||
*Optional*. Path to the application to push. If this isn't set then it will be read from the manifest instead.
|
||||
@@ -0,0 +1,2 @@
|
||||
*Required*. The address of the Cloud Controller in the Cloud Foundry deployment.
|
||||
username
|
||||
@@ -0,0 +1 @@
|
||||
*Required*. The organization to push the application to.
|
||||
@@ -0,0 +1 @@
|
||||
*Required*. The password used to authenticate.
|
||||
@@ -0,0 +1 @@
|
||||
*Optional*. Check the validity of the CF SSL cert. Defaults to `false`.
|
||||
@@ -0,0 +1 @@
|
||||
*Required*. The space to push the application to.
|
||||
@@ -0,0 +1 @@
|
||||
*Required*. The username used to authenticate.
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user