Dynamic CA and reconcile for vm_extensions
This commit is contained in:
@@ -144,12 +144,8 @@ public class BoshDeploymentManifestSchema implements YamlSchema {
|
||||
t_url.parseWith(BoshValueParsers.url("http", "https", "file"));
|
||||
|
||||
YAtomicType t_network_name = f.yenumFromDynamicValues("NetworkName", (dc) -> cloudConfigProvider.getModel(dc).getNetworkNames());
|
||||
|
||||
YAtomicType t_disk_type = f.yenumFromDynamicValues("DiskType", (dc) -> cloudConfigProvider.getModel(dc).getDiskTypes());
|
||||
|
||||
YAtomicType t_vm_extension = f.yatomic("VMExtension"); //TODO: resolve dynamically from 'cloud config' ? https://www.pivotaltracker.com/story/show/148703877
|
||||
t_vm_extension.parseWith(ValueParsers.NE_STRING);
|
||||
|
||||
YAtomicType t_vm_extension = f.yenumFromDynamicValues("VMExtension", (dc) -> cloudConfigProvider.getModel(dc).getVMExtensions());
|
||||
YAtomicType t_vm_type = f.yenumFromDynamicValues("VMType", (dc) -> cloudConfigProvider.getModel(dc).getVMTypes());
|
||||
|
||||
YAtomicType t_az = f.yenumFromDynamicValues("AvailabilityZone", (dc) -> cloudConfigProvider.getModel(dc).getAvailabilityZones());
|
||||
|
||||
@@ -70,29 +70,31 @@ public class BoshCommandCloudConfigProvider implements DynamicModelProvider<Clou
|
||||
}
|
||||
}
|
||||
|
||||
YamlTraversal VM_TYPE_NAMES = YamlPath.EMPTY
|
||||
private static final YamlTraversal VM_TYPE_NAMES = YamlPath.EMPTY
|
||||
.thenAnyChild()
|
||||
.thenValAt("vm_types")
|
||||
.thenAnyChild()
|
||||
.thenValAt("name");
|
||||
|
||||
protected static final YamlTraversal NETWORK_NAMES = YamlPath.EMPTY
|
||||
private static final YamlTraversal NETWORK_NAMES = YamlPath.EMPTY
|
||||
.thenAnyChild()
|
||||
.thenValAt("networks")
|
||||
.thenAnyChild()
|
||||
.thenValAt("name");
|
||||
|
||||
protected static final YamlTraversal AVAILABILITY_ZONES = YamlPath.EMPTY
|
||||
private static final YamlTraversal AVAILABILITY_ZONES = YamlPath.EMPTY
|
||||
.thenAnyChild()
|
||||
.thenValAt("azs")
|
||||
.thenAnyChild()
|
||||
.thenValAt("name");
|
||||
|
||||
protected static final YamlTraversal DISK_TYPES = YamlPath.EMPTY
|
||||
private static final YamlTraversal DISK_TYPES = YamlPath.EMPTY
|
||||
.thenAnyChild()
|
||||
.thenValAt("disk_types")
|
||||
.thenAnyChild()
|
||||
.thenValAt("name");
|
||||
private static final YamlTraversal VM_EXTENSIONS = YamlPath.EMPTY
|
||||
.thenAnyChild()
|
||||
.thenValAt("vm_extensions")
|
||||
.thenAnyChild()
|
||||
.thenValAt("name");
|
||||
|
||||
@Override
|
||||
public CloudConfigModel getModel(DynamicSchemaContext dc) throws Exception {
|
||||
@@ -121,6 +123,11 @@ public class BoshCommandCloudConfigProvider implements DynamicModelProvider<Clou
|
||||
return getNames(DISK_TYPES);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> getVMExtensions() {
|
||||
return getNames(VM_EXTENSIONS);
|
||||
}
|
||||
|
||||
private Collection<String> getNames(YamlTraversal namesPath) {
|
||||
return namesPath.traverseAmbiguously(ast)
|
||||
.flatMap(nameNode -> {
|
||||
|
||||
@@ -18,6 +18,7 @@ import java.util.Collection;
|
||||
public interface CloudConfigModel {
|
||||
Collection<String> getVMTypes();
|
||||
Collection<String> getNetworkNames();
|
||||
Collection<String> getAvailabilityZones();
|
||||
Collection<String> getDiskTypes();
|
||||
Collection<String> getAvailabilityZones();
|
||||
Collection<String> getDiskTypes();
|
||||
Collection<String> getVMExtensions();
|
||||
}
|
||||
|
||||
@@ -43,6 +43,7 @@ public class BoshEditorTest {
|
||||
}
|
||||
|
||||
@Test public void toplevelV2PropertyNamesKnown() throws Exception {
|
||||
cloudConfigProvider.readWith(() -> { throw new IOException("Can't read cloud config"); });
|
||||
Editor editor = harness.newEditor(
|
||||
"name: some-name\n" +
|
||||
"director_uuid: cf8dc1fc-9c42-4ffc-96f1-fbad983a6ce6\n" +
|
||||
@@ -1030,6 +1031,37 @@ public class BoshEditorTest {
|
||||
editor.assertProblems("bogus|unknown 'DiskType'. Valid values are: [small-disk, large-disk]");
|
||||
}
|
||||
|
||||
@Test public void reconcileVMExtensions() throws Exception {
|
||||
Editor editor = harness.newEditor(
|
||||
"name: my-first-deployment\n" +
|
||||
"instance_groups:\n" +
|
||||
"- name: my-server\n" +
|
||||
" vm_extensions:\n" +
|
||||
" - blah"
|
||||
);
|
||||
editor.ignoreProblem(YamlSchemaProblems.MISSING_PROPERTY);
|
||||
editor.assertProblems("blah|unknown 'VMExtension'. Valid values are: []");
|
||||
}
|
||||
|
||||
@Test public void reconcileVMExtensions2() throws Exception {
|
||||
cloudConfigProvider.readWith(() ->
|
||||
"vm_extensions:\n" +
|
||||
"- name: pub-lbs\n" +
|
||||
" cloud_properties:\n" +
|
||||
" elbs: [main]"
|
||||
);
|
||||
Editor editor = harness.newEditor(
|
||||
"name: my-first-deployment\n" +
|
||||
"instance_groups:\n" +
|
||||
"- name: my-server\n" +
|
||||
" vm_extensions:\n" +
|
||||
" - pub-lbs\n" +
|
||||
" - bogus"
|
||||
);
|
||||
editor.ignoreProblem(YamlSchemaProblems.MISSING_PROPERTY);
|
||||
editor.assertProblems("bogus|unknown 'VMExtension'. Valid values are: [pub-lbs]");
|
||||
}
|
||||
|
||||
@Test public void gotoReleaseDefinition() throws Exception {
|
||||
Editor editor = harness.newEditor(
|
||||
"name: foo\n" +
|
||||
|
||||
Reference in New Issue
Block a user