Dynamic CA / reconcile for persistent disk type
This commit is contained in:
@@ -145,8 +145,7 @@ public class BoshDeploymentManifestSchema implements YamlSchema {
|
||||
|
||||
YAtomicType t_network_name = f.yenumFromDynamicValues("NetworkName", (dc) -> cloudConfigProvider.getModel(dc).getNetworkNames());
|
||||
|
||||
YAtomicType t_disk_type = f.yatomic("DiskType"); //TODO: resolve from 'cloud config' https://www.pivotaltracker.com/story/show/148704001
|
||||
t_disk_type.parseWith(ValueParsers.NE_STRING);
|
||||
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);
|
||||
|
||||
@@ -88,6 +88,12 @@ public class BoshCommandCloudConfigProvider implements DynamicModelProvider<Clou
|
||||
.thenAnyChild()
|
||||
.thenValAt("name");
|
||||
|
||||
protected static final YamlTraversal DISK_TYPES = YamlPath.EMPTY
|
||||
.thenAnyChild()
|
||||
.thenValAt("disk_types")
|
||||
.thenAnyChild()
|
||||
.thenValAt("name");
|
||||
|
||||
@Override
|
||||
public CloudConfigModel getModel(DynamicSchemaContext dc) throws Exception {
|
||||
String block = getCloudConfigBlock();
|
||||
@@ -110,6 +116,11 @@ public class BoshCommandCloudConfigProvider implements DynamicModelProvider<Clou
|
||||
return getNames(AVAILABILITY_ZONES);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> getDiskTypes() {
|
||||
return getNames(DISK_TYPES);
|
||||
}
|
||||
|
||||
private Collection<String> getNames(YamlTraversal namesPath) {
|
||||
return namesPath.traverseAmbiguously(ast)
|
||||
.flatMap(nameNode -> {
|
||||
|
||||
@@ -19,4 +19,5 @@ public interface CloudConfigModel {
|
||||
Collection<String> getVMTypes();
|
||||
Collection<String> getNetworkNames();
|
||||
Collection<String> getAvailabilityZones();
|
||||
Collection<String> getDiskTypes();
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ public class BoshEditorTest {
|
||||
" vm_type: large\n" +
|
||||
" vm_extensions: [public-lbs]\n" +
|
||||
" stemcell: default\n" +
|
||||
" persistent_disk_type: medium\n" +
|
||||
" persistent_disk_type: large\n" +
|
||||
" networks:\n" +
|
||||
" - name: default\n" +
|
||||
"- name: redis-slave\n" +
|
||||
@@ -995,6 +995,41 @@ public class BoshEditorTest {
|
||||
);
|
||||
}
|
||||
|
||||
@Test public void reconcilePersistentDiskType() throws Exception {
|
||||
Editor editor = harness.newEditor(
|
||||
"name: my-first-deployment\n" +
|
||||
"instance_groups:\n" +
|
||||
"- name: my-server1\n" +
|
||||
" persistent_disk_type: default\n" +
|
||||
"- name: my-server2\n" +
|
||||
" persistent_disk_type: bogus\n" +
|
||||
"- name: my-server3\n" +
|
||||
" persistent_disk_type: large\n"
|
||||
);
|
||||
editor.ignoreProblem(YamlSchemaProblems.MISSING_PROPERTY);
|
||||
editor.assertProblems("bogus|unknown 'DiskType'. Valid values are: [default, large]");
|
||||
}
|
||||
|
||||
@Test public void reconcilePersistentDiskType2() throws Exception {
|
||||
cloudConfigProvider.readWith(() ->
|
||||
"disk_types:\n" +
|
||||
"- name: small-disk\n" +
|
||||
"- name: large-disk\n"
|
||||
);
|
||||
Editor editor = harness.newEditor(
|
||||
"name: my-first-deployment\n" +
|
||||
"instance_groups:\n" +
|
||||
"- name: my-server1\n" +
|
||||
" persistent_disk_type: small-disk\n" +
|
||||
"- name: my-server2\n" +
|
||||
" persistent_disk_type: bogus\n" +
|
||||
"- name: my-server3\n" +
|
||||
" persistent_disk_type: large-disk\n"
|
||||
);
|
||||
editor.ignoreProblem(YamlSchemaProblems.MISSING_PROPERTY);
|
||||
editor.assertProblems("bogus|unknown 'DiskType'. Valid values are: [small-disk, large-disk]");
|
||||
}
|
||||
|
||||
@Test public void gotoReleaseDefinition() throws Exception {
|
||||
Editor editor = harness.newEditor(
|
||||
"name: foo\n" +
|
||||
|
||||
Reference in New Issue
Block a user