Goto symbol for releases
This commit is contained in:
@@ -17,7 +17,6 @@ import java.util.UUID;
|
||||
import org.springframework.ide.vscode.commons.util.Assert;
|
||||
import org.springframework.ide.vscode.commons.util.Renderable;
|
||||
import org.springframework.ide.vscode.commons.util.Renderables;
|
||||
import org.springframework.ide.vscode.commons.util.ValueParser;
|
||||
import org.springframework.ide.vscode.commons.util.ValueParsers;
|
||||
import org.springframework.ide.vscode.commons.yaml.schema.YType;
|
||||
import org.springframework.ide.vscode.commons.yaml.schema.YTypeFactory;
|
||||
@@ -32,7 +31,6 @@ import org.springframework.ide.vscode.commons.yaml.schema.YamlSchema;
|
||||
import org.springframework.ide.vscode.commons.yaml.schema.constraints.Constraints;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableList.Builder;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
/**
|
||||
@@ -44,7 +42,7 @@ public class BoshDeploymentManifestSchema implements YamlSchema {
|
||||
private final YBeanType V1_TOPLEVEL_TYPE;
|
||||
private final YContextSensitive TOPLEVEL_TYPE;
|
||||
private final YTypeUtil TYPE_UTIL;
|
||||
|
||||
|
||||
private static final ImmutableSet<String> DEPRECATED_V1_PROPS = ImmutableSet.of("resource_pools", "networks", "compilation", "jobs", "disk_pools", "cloud_provider");
|
||||
private static final ImmutableSet<String> SHARED_V1_V2_PROPS = ImmutableSet.of("name", "director_uuid", "releases", "update", "properties");
|
||||
private ImmutableList<YType> definitionTypes = null;
|
||||
@@ -70,15 +68,16 @@ public class BoshDeploymentManifestSchema implements YamlSchema {
|
||||
public final YType t_uuid = f.yatomic("UUID").parseWith(UUID::fromString);
|
||||
public final YType t_integer_or_range = f.yatomic("Integer or Range")
|
||||
.parseWith(BoshValueParsers.INTEGER_OR_RANGE);
|
||||
private YAtomicType t_instance_group_name_def;
|
||||
private YAtomicType t_stemcell_alias_name_def;
|
||||
private YType t_instance_group_name_def;
|
||||
private YType t_stemcell_alias_name_def;
|
||||
private YType t_release_name_def;
|
||||
|
||||
public BoshDeploymentManifestSchema() {
|
||||
TYPE_UTIL = f.TYPE_UTIL;
|
||||
|
||||
|
||||
V2_TOPLEVEL_TYPE = createV2Schema();
|
||||
V1_TOPLEVEL_TYPE = createV1Schema(V2_TOPLEVEL_TYPE);
|
||||
|
||||
|
||||
TOPLEVEL_TYPE = f.contextAware("DeploymenManifestV1orV2", (dc) -> {
|
||||
boolean looksLikeV1 = dc.getDefinedProperties().stream().anyMatch(DEPRECATED_V1_PROPS::contains);
|
||||
return looksLikeV1 ? V1_TOPLEVEL_TYPE : V2_TOPLEVEL_TYPE;
|
||||
@@ -104,28 +103,32 @@ public class BoshDeploymentManifestSchema implements YamlSchema {
|
||||
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. " +
|
||||
"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_name_def = f.yatomic("StemcellAliasName")
|
||||
.parseWith(ValueParsers.NE_STRING);
|
||||
|
||||
t_release_name_def = f.yatomic("ReleaseName")
|
||||
.parseWith(ValueParsers.NE_STRING);
|
||||
|
||||
YAtomicType t_ip_address = f.yatomic("IPAddress"); //TODO: some kind of checking?
|
||||
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.yatomic("NetworkName"); //TODO: resolve from 'cloud config' https://www.pivotaltracker.com/story/show/148712155
|
||||
t_network_name.parseWith(ValueParsers.NE_STRING);
|
||||
|
||||
t_instance_group_name_def = f.yatomic("InstanceGroupName");
|
||||
t_instance_group_name_def.parseWith(ValueParsers.NE_STRING);
|
||||
|
||||
|
||||
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);
|
||||
|
||||
t_stemcell_alias_name_def = f.yatomic("StemcellAliasName");
|
||||
t_stemcell_alias_name_def.parseWith(ValueParsers.NE_STRING);
|
||||
|
||||
|
||||
YAtomicType t_stemcell_alias = f.yatomic("StemcellAlias"); //TODO: resolve from 'stemcells block' https://www.pivotaltracker.com/story/show/148706041
|
||||
t_stemcell_alias.parseWith(ValueParsers.NE_STRING);
|
||||
|
||||
@@ -137,12 +140,12 @@ public class BoshDeploymentManifestSchema implements YamlSchema {
|
||||
|
||||
YAtomicType t_az = f.yatomic("AvailabilityZone"); //TODO: resolve dynamically from 'cloud config': https://www.pivotaltracker.com/story/show/148704481
|
||||
t_az.parseWith(ValueParsers.NE_STRING);
|
||||
|
||||
|
||||
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));
|
||||
addProp(t_network, "default", f.yseq(t_ne_string)); //TODO: Can we determine the set of valid values? How?
|
||||
|
||||
|
||||
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);
|
||||
@@ -152,9 +155,9 @@ public class BoshDeploymentManifestSchema implements YamlSchema {
|
||||
t_version.parseWith(ValueParsers.NE_STRING);
|
||||
|
||||
YBeanType t_release = f.ybean("Release");
|
||||
addProp(t_release, "name", t_ne_string).isPrimary(true);
|
||||
addProp(t_release, "name", t_release_name_def).isPrimary(true);
|
||||
addProp(t_release, "version", t_version);
|
||||
//TODO: the checking here is just 'my best guess'. Unclarity remains:
|
||||
//TODO: the checking here is just 'my best guess'. Unclarity remains:
|
||||
// See: https://github.com/cloudfoundry/docs-bosh/issues/330
|
||||
addProp(t_release, "url", t_url);
|
||||
addProp(t_release, "sha1", t_ne_string);
|
||||
@@ -162,7 +165,7 @@ public class BoshDeploymentManifestSchema implements YamlSchema {
|
||||
t_release.require(Constraints.requireAtLeastOneOf("url", "version")); //allthough docs seem to imply you shouldn't define both url and version..
|
||||
//... it seems bosh tolerates it.
|
||||
t_release.require(BoshConstraints.SHA1_REQUIRED_FOR_HTTP_URL);
|
||||
|
||||
|
||||
YBeanType t_stemcell = f.ybean("Stemcell");
|
||||
addProp(t_stemcell, "alias", t_stemcell_alias_name_def).isRequired(true);
|
||||
addProp(t_stemcell, "version", t_ne_string).isRequired(true);
|
||||
@@ -198,7 +201,7 @@ public class BoshDeploymentManifestSchema implements YamlSchema {
|
||||
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) ->
|
||||
.map((YTypedProperty prop) ->
|
||||
f.yprop(prop).isRequired(false)
|
||||
)
|
||||
.toArray(sz -> new YTypedProperty[sz])
|
||||
@@ -209,10 +212,10 @@ public class BoshDeploymentManifestSchema implements YamlSchema {
|
||||
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_ne_string).isPrimary(true);
|
||||
addProp(t_variable, "type", f.yenum("VariableType", "certificate", "password", "rsa", "ssh")).isRequired(true);
|
||||
@@ -220,7 +223,7 @@ public class BoshDeploymentManifestSchema implements YamlSchema {
|
||||
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");
|
||||
}
|
||||
@@ -236,13 +239,13 @@ public class BoshDeploymentManifestSchema implements YamlSchema {
|
||||
public YTypeUtil getTypeUtil() {
|
||||
return TYPE_UTIL;
|
||||
}
|
||||
|
||||
|
||||
private YTypedPropertyImpl prop(AbstractType beanType, String name, YType type) {
|
||||
YTypedPropertyImpl prop = f.yprop(name, type);
|
||||
prop.setDescriptionProvider(descriptionFor(beanType, name));
|
||||
return prop;
|
||||
}
|
||||
|
||||
|
||||
public static Renderable descriptionFor(YType owner, String propName) {
|
||||
String typeName = owner.toString();
|
||||
return Renderables.fromClasspath(BoshDeploymentManifestSchema.class, "/desc/"+typeName+"/"+propName);
|
||||
@@ -262,7 +265,8 @@ public class BoshDeploymentManifestSchema implements YamlSchema {
|
||||
if (definitionTypes==null) {
|
||||
definitionTypes = ImmutableList.of(
|
||||
t_instance_group_name_def,
|
||||
t_stemcell_alias_name_def
|
||||
t_stemcell_alias_name_def,
|
||||
t_release_name_def
|
||||
);
|
||||
}
|
||||
return definitionTypes;
|
||||
|
||||
@@ -29,10 +29,8 @@ import org.springframework.ide.vscode.commons.yaml.completion.YamlCompletionEngi
|
||||
import org.springframework.ide.vscode.commons.yaml.hover.YamlHoverInfoProvider;
|
||||
import org.springframework.ide.vscode.commons.yaml.quickfix.YamlQuickfixes;
|
||||
import org.springframework.ide.vscode.commons.yaml.reconcile.ASTTypeCache;
|
||||
import org.springframework.ide.vscode.commons.yaml.reconcile.ITypeCollector;
|
||||
import org.springframework.ide.vscode.commons.yaml.reconcile.TypeBasedYamlSymbolHandler;
|
||||
import org.springframework.ide.vscode.commons.yaml.reconcile.YamlSchemaBasedReconcileEngine;
|
||||
import org.springframework.ide.vscode.commons.yaml.schema.YamlSchema;
|
||||
import org.springframework.ide.vscode.commons.yaml.structure.YamlStructureProvider;
|
||||
import org.yaml.snakeyaml.Yaml;
|
||||
|
||||
|
||||
@@ -661,12 +661,17 @@ public class BoshEditorTest {
|
||||
" networks:\n" +
|
||||
" - name: the-network\n" +
|
||||
" static_ips: []\n" +
|
||||
" default: []\n"
|
||||
" default: []\n" +
|
||||
"releases:\n" +
|
||||
"- name: one-release\n" +
|
||||
"- name: other-release\n"
|
||||
);
|
||||
editor.assertDocumentSymbols(
|
||||
"default|StemcellAlias",
|
||||
"foo-group|InstanceGroup",
|
||||
"bar-group|InstanceGroup"
|
||||
"bar-group|InstanceGroup",
|
||||
"one-release|Release",
|
||||
"other-release|Release"
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user