Cloudconfig editor: verify 'at least one of' constraints in schema
This commit is contained in:
@@ -110,11 +110,11 @@ public class BoshCloudConfigSchema extends SchemaSupport implements YamlSchema {
|
||||
addProp(t_disk_type, "cloud_properties", t_params);
|
||||
|
||||
this.toplevelType = f.ybean("CloudConfig");
|
||||
addProp(toplevelType, "azs", f.yseq(t_az)).isRequired(true);
|
||||
addProp(toplevelType, "networks", f.yseq(t_network)).isRequired(true);
|
||||
addProp(toplevelType, "vm_types", f.yseq(t_vm_type)).isRequired(true);
|
||||
addProp(toplevelType, "azs", f.yseq(t_az).notEmpty()).isRequired(true);
|
||||
addProp(toplevelType, "networks", f.yseq(t_network).notEmpty()).isRequired(true);
|
||||
addProp(toplevelType, "vm_types", f.yseq(t_vm_type).notEmpty()).isRequired(true);
|
||||
addProp(toplevelType, "vm_extensions", f.yseq(t_any));
|
||||
addProp(toplevelType, "disk_types", f.yseq(t_disk_type)).isRequired(true);
|
||||
addProp(toplevelType, "disk_types", f.yseq(t_disk_type).notEmpty()).isRequired(true);
|
||||
addProp(toplevelType, "compilation", t_compilation).isRequired(true);
|
||||
|
||||
ASTTypeCache astTypes = models.astTypes;
|
||||
|
||||
@@ -2422,4 +2422,20 @@ public class BoshEditorTest {
|
||||
editor.assertHoverContains("cloud_properties", "Describes any IaaS-specific properties needed to create disks");
|
||||
}
|
||||
|
||||
@Test public void cloudconfig_at_least_one_required() throws Exception {
|
||||
Editor editor = harness.newEditor(LanguageId.BOSH_CLOUD_CONFIG,
|
||||
"azs: []\n" +
|
||||
"vm_types: []\n" +
|
||||
"networks: []\n" +
|
||||
"disk_types: []\n" +
|
||||
"vm_extensions: []" //This one should be okay!
|
||||
);
|
||||
editor.ignoreProblem(YamlSchemaProblems.MISSING_PROPERTY);
|
||||
editor.assertProblems(
|
||||
"[]|At least one 'AZ' is required",
|
||||
"[]|At least one 'VMType' is required",
|
||||
"[]|At least one 'Network' is required",
|
||||
"[]|At least one 'DiskType' is required"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user