Flesh out basic schema for CloudConfig.compilation sub props
This commit is contained in:
@@ -11,20 +11,43 @@
|
|||||||
package org.springframework.ide.vscode.bosh;
|
package org.springframework.ide.vscode.bosh;
|
||||||
|
|
||||||
import org.springframework.ide.vscode.bosh.models.BoshModels;
|
import org.springframework.ide.vscode.bosh.models.BoshModels;
|
||||||
|
import org.springframework.ide.vscode.commons.util.ValueParsers;
|
||||||
import org.springframework.ide.vscode.commons.yaml.schema.YType;
|
import org.springframework.ide.vscode.commons.yaml.schema.YType;
|
||||||
import org.springframework.ide.vscode.commons.yaml.schema.YTypeFactory;
|
import org.springframework.ide.vscode.commons.yaml.schema.YTypeFactory;
|
||||||
|
import org.springframework.ide.vscode.commons.yaml.schema.YTypeFactory.AbstractType;
|
||||||
|
import org.springframework.ide.vscode.commons.yaml.schema.YTypeFactory.YAtomicType;
|
||||||
import org.springframework.ide.vscode.commons.yaml.schema.YTypeFactory.YBeanType;
|
import org.springframework.ide.vscode.commons.yaml.schema.YTypeFactory.YBeanType;
|
||||||
import org.springframework.ide.vscode.commons.yaml.schema.YTypeUtil;
|
import org.springframework.ide.vscode.commons.yaml.schema.YTypeUtil;
|
||||||
import org.springframework.ide.vscode.commons.yaml.schema.YamlSchema;
|
import org.springframework.ide.vscode.commons.yaml.schema.YamlSchema;
|
||||||
|
|
||||||
public class BoshCloudConfigSchema extends SchemaSupport implements YamlSchema {
|
public class BoshCloudConfigSchema extends SchemaSupport implements YamlSchema {
|
||||||
|
|
||||||
private YBeanType toplevelType;
|
private final YBeanType toplevelType;
|
||||||
private YType t_any;
|
private final YType t_az_ref;
|
||||||
|
private final YType t_vm_type_ref;
|
||||||
|
private final YType t_network_ref;
|
||||||
|
|
||||||
public BoshCloudConfigSchema(YTypeFactory f, BoshModels models) {
|
public BoshCloudConfigSchema(YTypeFactory f, BoshModels models) {
|
||||||
super(f);
|
super(f);
|
||||||
t_any = f.yany("Object");
|
|
||||||
|
AbstractType t_any = f.yany("Object");
|
||||||
|
AbstractType t_ne_string = f.yatomic("String")
|
||||||
|
.parseWith(ValueParsers.NE_STRING);
|
||||||
|
YAtomicType t_boolean = f.yenum("boolean", "true", "false");
|
||||||
|
|
||||||
|
t_az_ref = t_ne_string;
|
||||||
|
t_vm_type_ref = t_ne_string;
|
||||||
|
t_network_ref = t_ne_string;
|
||||||
|
|
||||||
|
AbstractType t_pos_integer = f.yatomic("Positive Integer")
|
||||||
|
.parseWith(ValueParsers.POS_INTEGER);
|
||||||
|
|
||||||
|
YBeanType t_compilation = f.ybean("Compilation");
|
||||||
|
addProp(t_compilation, "workers", t_pos_integer).isRequired(true);
|
||||||
|
addProp(t_compilation, "reuse_compilation_vms", t_boolean);
|
||||||
|
addProp(t_compilation, "az", t_az_ref).isRequired(true);
|
||||||
|
addProp(t_compilation, "vm_type", t_vm_type_ref).isRequired(true);
|
||||||
|
addProp(t_compilation, "network", t_network_ref).isRequired(true);
|
||||||
|
|
||||||
this.toplevelType = f.ybean("CloudConfig");
|
this.toplevelType = f.ybean("CloudConfig");
|
||||||
addProp(toplevelType, "azs", t_any).isRequired(true);
|
addProp(toplevelType, "azs", t_any).isRequired(true);
|
||||||
@@ -32,7 +55,7 @@ public class BoshCloudConfigSchema extends SchemaSupport implements YamlSchema {
|
|||||||
addProp(toplevelType, "vm_types", t_any).isRequired(true);
|
addProp(toplevelType, "vm_types", t_any).isRequired(true);
|
||||||
addProp(toplevelType, "vm_extensions", t_any);
|
addProp(toplevelType, "vm_extensions", t_any);
|
||||||
addProp(toplevelType, "disk_types", t_any).isRequired(true);
|
addProp(toplevelType, "disk_types", t_any).isRequired(true);
|
||||||
addProp(toplevelType, "compilation", t_any).isRequired(true);
|
addProp(toplevelType, "compilation", t_compilation).isRequired(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
*Required*. Name of the AZ defined in AZs section to use for creating compilation VMs.
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
*Required*. References a valid network name defined in the Networks block. BOSH assigns network properties to compilation VMs according to the type and properties of the specified network.
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
*Optional*. If `false`, BOSH creates a new compilation VM for each new package compilation and destroys the VM when compilation is complete. If `true`, compilation VMs are re-used when compiling packages. Defaults to `false`.
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
*Required*. Name of the VM type defined in VM types section to use for creating compilation VMs.
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
*Required*. The maximum number of compilation VMs.
|
||||||
@@ -1696,7 +1696,7 @@ public class BoshEditorTest {
|
|||||||
"- name: blah\n" +
|
"- name: blah\n" +
|
||||||
" <*>"
|
" <*>"
|
||||||
);
|
);
|
||||||
editor.assertContextualCompletions(LanguageId.BOSH_DEPLOYMENT, c -> c.getLabel().equals("jobs Snippet"),
|
editor.assertContextualCompletions(c -> c.getLabel().equals("jobs Snippet"),
|
||||||
"jo<*>"
|
"jo<*>"
|
||||||
, // ------
|
, // ------
|
||||||
"jobs:\n" +
|
"jobs:\n" +
|
||||||
@@ -1727,7 +1727,7 @@ public class BoshEditorTest {
|
|||||||
" - name: $1\n" +
|
" - name: $1\n" +
|
||||||
" release: $2<*>"
|
" release: $2<*>"
|
||||||
);
|
);
|
||||||
editor.assertContextualCompletions(LanguageId.BOSH_DEPLOYMENT, c -> c.getLabel().equals("→ jobs Snippet"),
|
editor.assertContextualCompletions(c -> c.getLabel().equals("→ jobs Snippet"),
|
||||||
"jo<*>"
|
"jo<*>"
|
||||||
, // ------
|
, // ------
|
||||||
" jobs:\n" +
|
" jobs:\n" +
|
||||||
@@ -1745,7 +1745,7 @@ public class BoshEditorTest {
|
|||||||
" type: aaa\n" +
|
" type: aaa\n" +
|
||||||
"<*>"
|
"<*>"
|
||||||
);
|
);
|
||||||
editor.assertContextualCompletions(LanguageId.BOSH_DEPLOYMENT, DEDENTED_COMPLETION.and(SNIPPET_COMPLETION),
|
editor.assertContextualCompletions(DEDENTED_COMPLETION.and(SNIPPET_COMPLETION),
|
||||||
" <*>"
|
" <*>"
|
||||||
, // ==>
|
, // ==>
|
||||||
"instance_groups:\n" +
|
"instance_groups:\n" +
|
||||||
@@ -1789,7 +1789,7 @@ public class BoshEditorTest {
|
|||||||
" type: aaa\n" +
|
" type: aaa\n" +
|
||||||
"<*>"
|
"<*>"
|
||||||
);
|
);
|
||||||
editor.assertContextualCompletions(LanguageId.BOSH_DEPLOYMENT, DEDENTED_COMPLETION.and(SNIPPET_COMPLETION.negate()),
|
editor.assertContextualCompletions(DEDENTED_COMPLETION.and(SNIPPET_COMPLETION.negate()),
|
||||||
" <*>"
|
" <*>"
|
||||||
, //==>
|
, //==>
|
||||||
"instance_groups:\n" +
|
"instance_groups:\n" +
|
||||||
@@ -1818,7 +1818,7 @@ public class BoshEditorTest {
|
|||||||
"- name: \n" +
|
"- name: \n" +
|
||||||
"<*>"
|
"<*>"
|
||||||
);
|
);
|
||||||
editor.assertContextualCompletions(LanguageId.BOSH_DEPLOYMENT, c -> c.getLabel().equals("→ jobs"),
|
editor.assertContextualCompletions(c -> c.getLabel().equals("→ jobs"),
|
||||||
"jo<*>"
|
"jo<*>"
|
||||||
, // ==>
|
, // ==>
|
||||||
" jobs:\n" +
|
" jobs:\n" +
|
||||||
@@ -1910,4 +1910,48 @@ public class BoshEditorTest {
|
|||||||
editor.assertHoverContains("compilation", "A compilation definition allows to specify VM characteristics.");
|
editor.assertHoverContains("compilation", "A compilation definition allows to specify VM characteristics.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test public void cloudconfig_compilation_subproperties() throws Exception {
|
||||||
|
Editor editor = harness.newEditor(LanguageId.BOSH_CLOUD_CONFIG,
|
||||||
|
"compilation:\n" +
|
||||||
|
" <*>"
|
||||||
|
);
|
||||||
|
editor.assertContextualCompletions(PLAIN_COMPLETION.or(SNIPPET_COMPLETION),
|
||||||
|
"<*>"
|
||||||
|
, // ==>
|
||||||
|
"workers: $1\n" +
|
||||||
|
" az: $2\n" +
|
||||||
|
" vm_type: $3\n" +
|
||||||
|
" network: $4<*>"
|
||||||
|
,
|
||||||
|
"az: <*>"
|
||||||
|
,
|
||||||
|
"network: <*>"
|
||||||
|
,
|
||||||
|
"reuse_compilation_vms: <*>"
|
||||||
|
,
|
||||||
|
"vm_type: <*>"
|
||||||
|
,
|
||||||
|
"workers: <*>"
|
||||||
|
);
|
||||||
|
|
||||||
|
editor = harness.newEditor(LanguageId.BOSH_CLOUD_CONFIG,
|
||||||
|
"compilation:\n" +
|
||||||
|
" workers: not-int\n" +
|
||||||
|
" reuse_compilation_vms: not-bool\n" +
|
||||||
|
" az: z1\n" +
|
||||||
|
" vm_type: default\n" +
|
||||||
|
" network: private\n"
|
||||||
|
);
|
||||||
|
editor.ignoreProblem(YamlSchemaProblems.MISSING_PROPERTY);
|
||||||
|
editor.assertProblems(
|
||||||
|
"not-int|NumberFormatException",
|
||||||
|
"not-bool|unknown 'boolean'"
|
||||||
|
);
|
||||||
|
editor.assertHoverContains("workers", "The maximum number of compilation VMs");
|
||||||
|
editor.assertHoverContains("reuse_compilation_vms", "If `false`, BOSH creates a new compilation VM");
|
||||||
|
editor.assertHoverContains("az", "Name of the AZ defined in AZs section");
|
||||||
|
editor.assertHoverContains("vm_type", "Name of the VM type defined in VM types section");
|
||||||
|
editor.assertHoverContains("network", "References a valid network name defined in the Networks block");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -377,7 +377,8 @@ public class Editor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void assertContextualCompletions(LanguageId language, Predicate<CompletionItem> isInteresting, String textBefore, String... textAfter) throws Exception {
|
public void assertContextualCompletions(Predicate<CompletionItem> isInteresting, String textBefore, String... textAfter) throws Exception {
|
||||||
|
LanguageId language = this.getLanguageId();
|
||||||
Editor editor = harness.newEditor(language, this.getText());
|
Editor editor = harness.newEditor(language, this.getText());
|
||||||
editor.reconcile(); //this ensures the conText is parsed and its AST is cached (will be used for
|
editor.reconcile(); //this ensures the conText is parsed and its AST is cached (will be used for
|
||||||
//dynamic CA when the conText + textBefore is not parsable.
|
//dynamic CA when the conText + textBefore is not parsable.
|
||||||
@@ -391,7 +392,7 @@ public class Editor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void assertContextualCompletions(String textBefore, String... textAfter) throws Exception {
|
public void assertContextualCompletions(String textBefore, String... textAfter) throws Exception {
|
||||||
assertContextualCompletions(getLanguageId(), (x) -> true, textBefore, textAfter);
|
assertContextualCompletions((x) -> true, textBefore, textAfter);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String replaceSelection(String replacement) {
|
private String replaceSelection(String replacement) {
|
||||||
|
|||||||
Reference in New Issue
Block a user