use of org.springframework.ide.vscode.bosh.models.StemcellData in project sts4 by spring-projects.
the class BoshEditorTest method contentAssistStemcellVersionFromDirector.
@Test
public void contentAssistStemcellVersionFromDirector() throws Exception {
Editor editor;
stemcellsProvider = provideStemcellsFrom(new StemcellData("ubuntu-agent", "123.4", "ubuntu"), new StemcellData("ubuntu-agent", "222.2", "ubuntu"), new StemcellData("centos-agent", "222.2", "centos"), new StemcellData("centos-agent", "333.3", "centos"));
editor = harness.newEditor("stemcells:\n" + "- alias: good\n" + " name: centos-agent\n" + " version: <*>\n");
editor.assertContextualCompletions("<*>", "222.2<*>", "333.3<*>", "latest<*>");
editor = harness.newEditor("stemcells:\n" + "- alias: good\n" + " os: ubuntu\n" + " version: <*>\n");
editor.assertContextualCompletions("<*>", "123.4<*>", "222.2<*>", "latest<*>");
editor = harness.newEditor("stemcells:\n" + "- alias: good\n" + " version: <*>\n");
editor.assertContextualCompletions("<*>", "123.4<*>", "222.2<*>", "333.3<*>", "latest<*>");
// when os and name are 'bogus' at least suggest proposals based on other prop
editor = harness.newEditor("stemcells:\n" + "- alias: good\n" + " name: centos-agent\n" + " os: bogus\n" + " version: <*>\n");
editor.assertContextualCompletions("<*>", "222.2<*>", "333.3<*>", "latest<*>");
editor = harness.newEditor("stemcells:\n" + "- alias: good\n" + " os: centos\n" + " name: bogus\n" + " version: <*>\n");
editor.assertContextualCompletions("<*>", "222.2<*>", "333.3<*>", "latest<*>");
// when the os and name disagree, merge the proposals for both:
editor = harness.newEditor("stemcells:\n" + "- alias: good\n" + // Contradicts the name
" os: centos\n" + // Contradicts the os
" name: ubuntu-agent\n" + " version: <*>\n");
editor.assertContextualCompletions("<*>", "123.4<*>", "222.2<*>", "333.3<*>", "latest<*>");
}
use of org.springframework.ide.vscode.bosh.models.StemcellData in project sts4 by spring-projects.
the class BoshEditorTest method reconcileStemcellVersionFromDirector.
@Test
public void reconcileStemcellVersionFromDirector() throws Exception {
Editor editor;
stemcellsProvider = provideStemcellsFrom(new StemcellData("ubuntu-agent", "123.4", "ubuntu"), new StemcellData("ubuntu-agent", "222.2", "ubuntu"), new StemcellData("centos-agent", "222.2", "centos"), new StemcellData("centos-agent", "333.3", "centos"));
editor = harness.newEditor("stemcells:\n" + "- alias: aaa\n" + " name: centos-agent\n" + " version: 222.2\n" + "- alias: bbb\n" + " name: centos-agent\n" + " version: 123.4\n" + "- alias: ddd\n" + " os: ubuntu\n" + " version: 333.3\n" + "- alias: eee\n" + " os: ubuntu\n" + " version: latest\n");
editor.ignoreProblem(YamlSchemaProblems.MISSING_PROPERTY);
editor.assertProblems("123.4|unknown 'StemcellVersion[name=centos-agent]'. Valid values are: [222.2, 333.3, latest]", "333.3|unknown 'StemcellVersion[os=ubuntu]'. Valid values are: [123.4, 222.2, latest]");
}
use of org.springframework.ide.vscode.bosh.models.StemcellData in project sts4 by spring-projects.
the class BoshDeploymentManifestSchema method createV2Schema.
private YBeanType createV2Schema() {
YBeanType v2Schema = f.ybean("BoshDeploymentManifest");
addProp(v2Schema, "name", t_ne_string).isPrimary(true);
addProp(v2Schema, "director_uuid", t_uuid).isDeprecated("bosh v2 CLI no longer checks or requires director_uuid in the deployment manifest. " + "To achieve similar safety make sure to give unique deployment names across environments.");
t_instance_group_name_def = f.yatomic("InstanceGroupName").parseWith(ValueParsers.NE_STRING);
t_stemcell_alias_def = f.yatomic("StemcellAlias").parseWith(ValueParsers.NE_STRING);
t_stemcell_alias_ref = f.yenumFromDynamicValues("StemcellAlias", (dc) -> PartialCollection.compute(() -> astTypes.getDefinedNames(dc, t_stemcell_alias_def)));
t_release_name_def = f.yenumFromDynamicValues("ReleaseName", (dc) -> {
PartialCollection<String> releaseNames = PartialCollection.compute(() -> releasesProvider.getModel(dc).getReleaseNames());
return StringUtil.hasText(getCurrentEntityProperty(dc, "url")) ? releaseNames.addUncertainty() : releaseNames;
});
t_release_name_ref = f.yenumFromDynamicValues("ReleaseName", (dc) -> PartialCollection.compute(() -> astTypes.getDefinedNames(dc, t_release_name_def)));
t_var_name_def = f.yatomic("VariableName").parseWith(ValueParsers.NE_STRING);
// TODO: some kind of checking?
YAtomicType t_ip_address = f.yatomic("IPAddress");
t_ip_address.parseWith(ValueParsers.NE_STRING);
YAtomicType t_url = f.yatomic("URL");
t_url.parseWith(BoshValueParsers.url("http", "https", "file"));
YAtomicType t_network_name = f.yenumFromDynamicValues("NetworkName", (dc) -> PartialCollection.compute(() -> cloudConfigProvider.getModel(dc).getNetworkNames()));
YAtomicType t_disk_type = f.yenumFromDynamicValues("DiskType", (dc) -> PartialCollection.compute(() -> cloudConfigProvider.getModel(dc).getDiskTypes()));
YAtomicType t_vm_extension = f.yenumFromDynamicValues("VMExtension", (dc) -> PartialCollection.compute(() -> cloudConfigProvider.getModel(dc).getVMExtensions()));
YAtomicType t_vm_type = f.yenumFromDynamicValues("VMType", (dc) -> PartialCollection.compute(() -> cloudConfigProvider.getModel(dc).getVMTypes()));
YAtomicType t_az = f.yenumFromDynamicValues("AvailabilityZone", (dc) -> PartialCollection.compute(() -> cloudConfigProvider.getModel(dc).getAvailabilityZones()));
YBeanType t_network = f.ybean("Network");
addProp(t_network, "name", t_network_name).isRequired(true);
addProp(t_network, "static_ips", f.yseq(t_ip_address));
// TODO: Can we determine the set of valid values? How?
addProp(t_network, "default", f.yseq(t_ne_string));
YBeanType t_instance_group_env = f.ybean("InstanceGroupEnv");
addProp(t_instance_group_env, "bosh", t_params);
addProp(t_instance_group_env, "password", t_ne_string);
YType t_release_version = f.yenumFromDynamicValues("ReleaseVersion", // message formatter:
dc -> (s, values) -> {
String name = getCurrentEntityProperty(dc, "name");
if (StringUtil.hasText(name)) {
return "'" + s + "' is an unknown 'ReleaseVersion[name=" + name + "]'. Valid values are: " + values;
} else {
return "'" + s + "' is an unknown 'ReleaseVersion'. Valid values are: " + values;
}
}, // value provider:
dc -> {
PartialCollection<ReleaseData> releases = PartialCollection.compute(() -> releasesProvider.getModel(dc).getReleases());
if (StringUtil.hasText(getCurrentEntityProperty(dc, "url"))) {
releases = releases.addUncertainty();
} else {
String name = getCurrentEntityProperty(dc, "name");
if (StringUtil.hasText(name)) {
releases = releases.map(r -> name.equals(r.getName()) ? r : null);
}
}
return releases.map(r -> r.getVersion()).add("latest");
});
YBeanType t_release = f.ybean("Release");
addProp(t_release, "name", t_release_name_def).isPrimary(true);
addProp(t_release, "version", t_release_version).isRequired(true);
addProp(t_release, "url", t_url);
addProp(t_release, "sha1", t_ne_string);
t_release.require(BoshConstraints.SHA1_REQUIRED_FOR_HTTP_URL);
addProp(v2Schema, "releases", f.yseq(t_release)).isRequired(true);
YBeanType t_stemcell = f.ybean("Stemcell");
YType t_stemcell_name_ref = f.yenumFromDynamicValues("StemcellName", (dc) -> PartialCollection.compute(() -> stemcellsProvider.getModel(dc).getStemcellNames()));
YType t_stemcell_os_ref = f.yenumFromDynamicValues("StemcellOs", (dc) -> PartialCollection.compute(() -> stemcellsProvider.getModel(dc).getStemcellOss()));
YType t_stemcell_version_ref = f.yenumFromDynamicValues("StemcellVersion", (dc) -> (parseString, validValues) -> {
try {
Predicate<StemcellData> filter = getCurrentStemcell(dc).createVersionFilter();
if (filter != StemcellModel.ALLWAYS_TRUE_FILTER) {
return "'" + parseString + "' is an unknown 'StemcellVersion[" + filter + "]'. Valid values are: " + validValues;
}
} catch (Exception e) {
// ignore (parse error most likely)
}
return "'" + parseString + "' is an unknown 'StemcellVersion'. Valid values are: " + validValues;
}, (dc) -> {
Predicate<StemcellData> filter = getCurrentStemcell(dc).createVersionFilter();
return PartialCollection.compute(() -> stemcellsProvider.getModel(dc).getStemcells()).map(sc -> filter.test(sc) ? sc.getVersion() : null).add("latest");
});
addProp(t_stemcell, "alias", t_stemcell_alias_def).isPrimary(true);
addProp(t_stemcell, "version", t_stemcell_version_ref).isRequired(true);
addProp(t_stemcell, "name", t_stemcell_name_ref);
addProp(t_stemcell, "os", t_stemcell_os_ref);
t_stemcell.requireOneOf("name", "os");
addProp(v2Schema, "stemcells", f.yseq(t_stemcell)).isRequired(true);
YBeanType t_update = f.ybean("Update");
addProp(t_update, "canaries", t_strictly_pos_integer).isRequired(true);
addProp(t_update, "max_in_flight", t_pos_integer).isRequired(true);
addProp(t_update, "canary_watch_time", t_integer_or_range).isRequired(true);
addProp(t_update, "update_watch_time", t_integer_or_range).isRequired(true);
addProp(t_update, "serial", t_boolean);
addProp(v2Schema, "update", t_update).isRequired(true);
YBeanType t_job = f.ybean("Job");
addProp(t_job, "name", t_ne_string).isRequired(true);
addProp(t_job, "release", t_release_name_ref).isRequired(true);
addProp(t_job, "consumes", t_params);
addProp(t_job, "provides", t_params);
addProp(t_job, "properties", t_params);
YBeanType t_instance_group = f.ybean("InstanceGroup");
addProp(t_instance_group, "name", t_instance_group_name_def).isPrimary(true);
addProp(t_instance_group, "azs", f.yseq(t_az)).isRequired(true);
// Strictly positive? Or zero is okay?
addProp(t_instance_group, "instances", t_pos_integer).isRequired(true);
addProp(t_instance_group, "jobs", f.yseq(t_job)).isRequired(true);
addProp(t_instance_group, "vm_type", t_vm_type).isRequired(true);
addProp(t_instance_group, "vm_extensions", f.yseq(t_vm_extension));
addProp(t_instance_group, "stemcell", t_stemcell_alias_ref).isRequired(true);
addProp(t_instance_group, "persistent_disk_type", t_disk_type);
addProp(t_instance_group, "networks", f.yseq(t_network)).isRequired(true);
YType t_update_override = f.ybean("UpdateOverrides", t_update.getProperties().stream().map((YTypedProperty prop) -> f.yprop(prop).isRequired(false)).toArray(sz -> new YTypedProperty[sz]));
addProp(t_instance_group, "update", t_update_override);
// TODO: https://www.pivotaltracker.com/story/show/148712595
YType t_migration = t_params;
addProp(t_instance_group, "migrated_from", f.yseq(t_migration));
addProp(t_instance_group, "lifecycle", f.yenum("WorkloadType", "service", "errand"));
addProp(t_instance_group, "properties", t_params).isDeprecated("Deprecated in favor of job level properties and links");
addProp(t_instance_group, "env", t_instance_group_env);
addProp(v2Schema, "instance_groups", f.yseq(t_instance_group)).isRequired(true);
addProp(v2Schema, "properties", t_params).isDeprecated("Deprecated in favor of job level properties and links");
YBeanType t_variable = f.ybean("Variable");
addProp(t_variable, "name", t_var_name_def).isPrimary(true);
YType t_variable_type = f.yenum("VariableType", "certificate", "password", "rsa", "ssh").parseWith(// Override the parser -> no errors / warnings... in theory there could be other valid values.
ValueParsers.NE_STRING);
addProp(t_variable, "type", t_variable_type).isRequired(true);
addProp(t_variable, "options", t_params);
addProp(v2Schema, "variables", f.yseq(t_variable));
addProp(v2Schema, "tags", t_params);
for (String v1Prop : DEPRECATED_V1_PROPS) {
addProp(v2Schema, v1Prop, t_any).isDeprecated("Deprecated: '" + v1Prop + "' is a V1 schema property. Consider migrating your deployment manifest to V2");
}
for (YType defType : getDefinitionTypes()) {
v2Schema.require(Constraints.uniqueDefinition(this.astTypes, defType, YamlSchemaProblems.problemType("BOSH_DUPLICATE_" + defType)));
}
return v2Schema;
}
Aggregations