use of org.springframework.ide.vscode.bosh.models.ReleaseData in project sts4 by spring-projects.
the class BoshEditorTest method reconcileReleaseVersion.
@Test
public void reconcileReleaseVersion() throws Exception {
Editor editor;
releasesProvider = provideReleasesFrom(new ReleaseData("foo", "123.4"), new ReleaseData("foo", "222.2"), new ReleaseData("bar", "222.2"), new ReleaseData("bar", "333.3"));
editor = harness.newEditor("releases:\n" + "- version: bogus\n" + "- version: url-makes-this-possibly-correct\n" + " url: file:///relesease-folder/blah-release.tar.gz\n" + "- name: bar\n" + " version: url-makes-this-also-possibly-correct\n" + " url: file:///relesease-folder/other-release.tar.gz");
editor.ignoreProblem(YamlSchemaProblems.MISSING_PROPERTY);
editor.assertProblems("bogus|unknown 'ReleaseVersion'. Valid values are: [123.4, 222.2, 333.3, latest]");
editor = harness.newEditor("releases:\n" + "- version: 123.4\n" + "- version: latest\n" + "- version: bogus\n");
editor.ignoreProblem(YamlSchemaProblems.MISSING_PROPERTY);
editor.assertProblems("bogus|unknown 'ReleaseVersion'. Valid values are: [123.4, 222.2, 333.3, latest]");
editor = harness.newEditor("releases:\n" + "- name: foo\n" + " version: 123.4\n");
editor.ignoreProblem(YamlSchemaProblems.MISSING_PROPERTY);
editor.assertProblems();
editor = harness.newEditor("releases:\n" + "- name: foo\n" + " version: 222.2\n");
editor.ignoreProblem(YamlSchemaProblems.MISSING_PROPERTY);
editor.assertProblems();
editor = harness.newEditor("releases:\n" + "- name: foo\n" + " version: 333.3\n");
editor.ignoreProblem(YamlSchemaProblems.MISSING_PROPERTY);
editor.assertProblems("333.3|unknown 'ReleaseVersion[name=foo]'. Valid values are: [123.4, 222.2, latest]");
}
use of org.springframework.ide.vscode.bosh.models.ReleaseData in project sts4 by spring-projects.
the class BoshEditorTest method reconcileReleaseNameDef.
@Test
public void reconcileReleaseNameDef() throws Exception {
releasesProvider = provideReleasesFrom(new ReleaseData("foo", "123.4"), new ReleaseData("foo", "222.2"), new ReleaseData("bar", "222.2"), new ReleaseData("bar", "333.3"));
Editor editor = harness.newEditor("releases:\n" + "- name: foo\n" + "- name: bar\n" + "- name: bogus\n" + "- name: url-makes-this-ok\n" + " url: file://blah");
editor.ignoreProblem(YamlSchemaProblems.MISSING_PROPERTY);
editor.assertProblems("bogus|unknown 'ReleaseName'. Valid values are: [foo, bar]");
}
use of org.springframework.ide.vscode.bosh.models.ReleaseData in project sts4 by spring-projects.
the class BoshEditorTest method contentAssistReleaseVersion.
@Test
public void contentAssistReleaseVersion() throws Exception {
releasesProvider = provideReleasesFrom(new ReleaseData("foo", "123.4"), new ReleaseData("foo", "222.2"), new ReleaseData("bar", "222.2"), new ReleaseData("bar", "333.3"));
Editor editor = harness.newEditor("releases:\n" + "- version: <*>");
editor.assertContextualCompletions("<*>", "123.4<*>", "222.2<*>", "333.3<*>", "latest<*>");
editor = harness.newEditor("releases:\n" + "- name: foo\n" + " version: <*>");
editor.assertContextualCompletions("<*>", "123.4<*>", "222.2<*>", "latest<*>");
// Still get all suggestions even when 'url' property is added
editor = harness.newEditor("releases:\n" + "- version: <*>\n" + " url: blah");
editor.assertContextualCompletions("<*>", "123.4<*>", "222.2<*>", "333.3<*>", "latest<*>");
editor = harness.newEditor("releases:\n" + "- name: foo\n" + " url: blah\n" + " version: <*>");
editor.assertContextualCompletions("<*>", "123.4<*>", "222.2<*>", "333.3<*>", "latest<*>");
}
use of org.springframework.ide.vscode.bosh.models.ReleaseData in project sts4 by spring-projects.
the class BoshEditorTest method contentAssistReleaseNameDef.
@Test
public void contentAssistReleaseNameDef() throws Exception {
releasesProvider = provideReleasesFrom(new ReleaseData("foo", "123.4"), new ReleaseData("foo", "222.2"), new ReleaseData("bar", "222.2"), new ReleaseData("bar", "333.3"));
Editor editor = harness.newEditor("releases:\n" + "- name: <*>");
editor.assertContextualCompletions("<*>", "bar<*>", "foo<*>");
}
use of org.springframework.ide.vscode.bosh.models.ReleaseData 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