CA and reconcile for vm_type reference in cloud-config editor

This commit is contained in:
Kris De Volder
2017-08-08 14:58:10 -07:00
parent 4eda08364d
commit 8c060d7980
2 changed files with 69 additions and 2 deletions

View File

@@ -15,6 +15,7 @@ import java.util.Collection;
import org.apache.commons.lang3.tuple.Pair;
import org.springframework.ide.vscode.bosh.models.BoshModels;
import org.springframework.ide.vscode.commons.util.CollectorUtil;
import org.springframework.ide.vscode.commons.util.PartialCollection;
import org.springframework.ide.vscode.commons.util.ValueParsers;
import org.springframework.ide.vscode.commons.yaml.reconcile.ASTTypeCache;
import org.springframework.ide.vscode.commons.yaml.reconcile.YamlSchemaProblems;
@@ -52,8 +53,10 @@ public class BoshCloudConfigSchema extends SchemaSupport implements YamlSchema {
YType t_params = f.ymap(t_ne_string, t_any);
t_az_ref = t_ne_string;
t_vm_type_ref = t_ne_string;
t_vm_type_def = f.yatomic("VMTypeName").parseWith(ValueParsers.NE_STRING);
t_vm_type_ref = f.yenumFromDynamicValues("VMTypeName", (dc) -> PartialCollection.compute(() ->
models.astTypes.getDefinedNames(dc, t_vm_type_def)
));
t_network_ref = t_ne_string;
YBeanType t_compilation = f.ybean("Compilation");

View File

@@ -1945,7 +1945,8 @@ public class BoshEditorTest {
editor.ignoreProblem(YamlSchemaProblems.MISSING_PROPERTY);
editor.assertProblems(
"not-int|NumberFormatException",
"not-bool|unknown 'boolean'"
"not-bool|unknown 'boolean'",
"default|unknown 'VMTypeName'"
);
editor.assertHoverContains("workers", "The maximum number of compilation VMs");
editor.assertHoverContains("reuse_compilation_vms", "If `false`, BOSH creates a new compilation VM");
@@ -1996,4 +1997,67 @@ public class BoshEditorTest {
editor.assertHoverContains("cloud_properties", "Describes any IaaS-specific properties needed to create VMs");
}
@Test public void cloudconfig_vm_types_reference() throws Exception {
Editor editor = harness.newEditor(LanguageId.BOSH_CLOUD_CONFIG,
"vm_types:\n" +
"- name: small\n" +
" cloud_properties:\n" +
" instance_type: t2.micro\n" +
" ephemeral_disk: {size: 3000, type: gp2}\n" +
"- name: medium\n" +
" cloud_properties:\n" +
" instance_type: m3.medium\n" +
" ephemeral_disk: {size: 30000, type: gp2}\n" +
"compilation:\n" +
" workers: 5\n" +
" reuse_compilation_vms: true\n" +
" az: z1\n" +
" vm_type: <*>\n" +
" network: private"
);
editor.assertContextualCompletions("<*>",
"medium<*>",
"small<*>"
);
editor = harness.newEditor(LanguageId.BOSH_CLOUD_CONFIG,
"vm_types:\n" +
"- name: small\n" +
" cloud_properties:\n" +
" instance_type: t2.micro\n" +
" ephemeral_disk: {size: 3000, type: gp2}\n" +
"- name: medium\n" +
" cloud_properties:\n" +
" instance_type: m3.medium\n" +
" ephemeral_disk: {size: 30000, type: gp2}\n" +
"compilation:\n" +
" workers: 5\n" +
" reuse_compilation_vms: true\n" +
" az: z1\n" +
" vm_type: medium\n" +
" network: private"
);
editor.ignoreProblem(YamlSchemaProblems.MISSING_PROPERTY);
editor.assertProblems(/*NONE*/);
editor = harness.newEditor(LanguageId.BOSH_CLOUD_CONFIG,
"vm_types:\n" +
"- name: small\n" +
" cloud_properties:\n" +
" instance_type: t2.micro\n" +
" ephemeral_disk: {size: 3000, type: gp2}\n" +
"- name: medium\n" +
" cloud_properties:\n" +
" instance_type: m3.medium\n" +
" ephemeral_disk: {size: 30000, type: gp2}\n" +
"compilation:\n" +
" workers: 5\n" +
" reuse_compilation_vms: true\n" +
" az: z1\n" +
" vm_type: woot-vm\n" +
" network: private"
);
editor.ignoreProblem(YamlSchemaProblems.MISSING_PROPERTY);
editor.assertProblems("woot-vm|unknown 'VMTypeName'");
}
}