diff --git a/headless-services/bosh-language-server/src/main/java/org/springframework/ide/vscode/bosh/BoshCloudConfigSchema.java b/headless-services/bosh-language-server/src/main/java/org/springframework/ide/vscode/bosh/BoshCloudConfigSchema.java index e19a47c40..12edaa271 100644 --- a/headless-services/bosh-language-server/src/main/java/org/springframework/ide/vscode/bosh/BoshCloudConfigSchema.java +++ b/headless-services/bosh-language-server/src/main/java/org/springframework/ide/vscode/bosh/BoshCloudConfigSchema.java @@ -132,6 +132,15 @@ public class BoshCloudConfigSchema extends SchemaSupport implements YamlSchema { AbstractType t_dynamic_nw = f.ybean("DynamicNetwork"); addProp(t_dynamic_nw, "dns", f.yseq(t_ip_address)); addProp(t_dynamic_nw, "cloud_properties", t_params); + { + YBeanType t_subnet = f.ybean("Subnet[Dynamic]"); + addProp(t_subnet, "dns", f.yseq(t_ip_address)); + addProp(t_subnet, "az", t_az_ref); + addProp(t_subnet, "azs", f.yseq(t_az_ref)); + addProp(t_subnet, "cloud_properties", t_params); + + addProp(t_dynamic_nw, "subnets", f.yseq(t_subnet)); + } t_dynamic_nw.require(Constraints.mutuallyExclusive("dns", "subnets")); t_dynamic_nw.require(Constraints.mutuallyExclusive("cloud_properties", "subnets")); diff --git a/headless-services/bosh-language-server/src/main/resources/cloud-config/DynamicNetwork/cloud_properties.md b/headless-services/bosh-language-server/src/main/resources/cloud-config/DynamicNetwork/cloud_properties.md new file mode 100644 index 000000000..e6be69183 --- /dev/null +++ b/headless-services/bosh-language-server/src/main/resources/cloud-config/DynamicNetwork/cloud_properties.md @@ -0,0 +1,11 @@ +Describes any IaaS-specific properties for the network. Default is {} (empty Hash). + +See: + +- [AWS CPI network cloud properties](https://bosh.io/docs/aws-cpi.html#networks) +- [Azure CPI network cloud properties](https://bosh.io/docs/azure-cpi.html#networks) +- [OpenStack CPI network cloud properties](https://bosh.io/docs/openstack-cpi.html#networks) +- [Softlayer CPI network cloud properties](https://bosh.io/docs/softlayer-cpi.html#networks) +- [Google Cloud Platform CPI network cloud properties](https://bosh.io/docs/google-cpi.html#networks) +- [vSphere CPI network cloud properties](https://bosh.io/docs/vsphere-cpi.html#networks) +- [vCloud CPI network cloud properties](https://bosh.io/docs/vcloud-cpi.html#networks) \ No newline at end of file diff --git a/headless-services/bosh-language-server/src/main/resources/cloud-config/DynamicNetwork/dns.md b/headless-services/bosh-language-server/src/main/resources/cloud-config/DynamicNetwork/dns.md new file mode 100644 index 000000000..05a927868 --- /dev/null +++ b/headless-services/bosh-language-server/src/main/resources/cloud-config/DynamicNetwork/dns.md @@ -0,0 +1 @@ +DNS IP addresses for this network. \ No newline at end of file diff --git a/headless-services/bosh-language-server/src/main/resources/cloud-config/DynamicNetwork/subnets.md b/headless-services/bosh-language-server/src/main/resources/cloud-config/DynamicNetwork/subnets.md new file mode 100644 index 000000000..3fb971000 --- /dev/null +++ b/headless-services/bosh-language-server/src/main/resources/cloud-config/DynamicNetwork/subnets.md @@ -0,0 +1 @@ +Lists subnets in this network. \ No newline at end of file diff --git a/headless-services/bosh-language-server/src/main/resources/cloud-config/Subnet[Dynamic]/az.md b/headless-services/bosh-language-server/src/main/resources/cloud-config/Subnet[Dynamic]/az.md new file mode 100644 index 000000000..11d1727f9 --- /dev/null +++ b/headless-services/bosh-language-server/src/main/resources/cloud-config/Subnet[Dynamic]/az.md @@ -0,0 +1 @@ +AZ associated with this subnet (should only be used when using [first class AZs](https://bosh.io/docs/azs.html)). Example: `z1`. \ No newline at end of file diff --git a/headless-services/bosh-language-server/src/main/resources/cloud-config/Subnet[Dynamic]/azs.md b/headless-services/bosh-language-server/src/main/resources/cloud-config/Subnet[Dynamic]/azs.md new file mode 100644 index 000000000..57ebb7073 --- /dev/null +++ b/headless-services/bosh-language-server/src/main/resources/cloud-config/Subnet[Dynamic]/azs.md @@ -0,0 +1 @@ +List of AZs associated with this subnet (should only be used when using [first class AZs](https://bosh.io/docs/azs.html)). Example: `[z1, z2]`. \ No newline at end of file diff --git a/headless-services/bosh-language-server/src/main/resources/cloud-config/Subnet[Dynamic]/cloud_properties.md b/headless-services/bosh-language-server/src/main/resources/cloud-config/Subnet[Dynamic]/cloud_properties.md new file mode 100644 index 000000000..7d246f597 --- /dev/null +++ b/headless-services/bosh-language-server/src/main/resources/cloud-config/Subnet[Dynamic]/cloud_properties.md @@ -0,0 +1,11 @@ +Describes any IaaS-specific properties for the subnet. Default is {} (empty Hash). + +See: + +- [AWS CPI network cloud properties](https://bosh.io/docs/aws-cpi.html#networks) +- [Azure CPI network cloud properties](https://bosh.io/docs/azure-cpi.html#networks) +- [OpenStack CPI network cloud properties](https://bosh.io/docs/openstack-cpi.html#networks) +- [Softlayer CPI network cloud properties](https://bosh.io/docs/softlayer-cpi.html#networks) +- [Google Cloud Platform CPI network cloud properties](https://bosh.io/docs/google-cpi.html#networks) +- [vSphere CPI network cloud properties](https://bosh.io/docs/vsphere-cpi.html#networks) +- [vCloud CPI network cloud properties](https://bosh.io/docs/vcloud-cpi.html#networks) \ No newline at end of file diff --git a/headless-services/bosh-language-server/src/main/resources/cloud-config/Subnet[Dynamic]/dns.md b/headless-services/bosh-language-server/src/main/resources/cloud-config/Subnet[Dynamic]/dns.md new file mode 100644 index 000000000..1882b628d --- /dev/null +++ b/headless-services/bosh-language-server/src/main/resources/cloud-config/Subnet[Dynamic]/dns.md @@ -0,0 +1 @@ +DNS IP addresses for this subnet. \ No newline at end of file diff --git a/headless-services/bosh-language-server/src/test/java/org/springframework/ide/vscode/bosh/BoshEditorTest.java b/headless-services/bosh-language-server/src/test/java/org/springframework/ide/vscode/bosh/BoshEditorTest.java index 69bee0726..6ac572d96 100644 --- a/headless-services/bosh-language-server/src/test/java/org/springframework/ide/vscode/bosh/BoshEditorTest.java +++ b/headless-services/bosh-language-server/src/test/java/org/springframework/ide/vscode/bosh/BoshEditorTest.java @@ -2227,4 +2227,78 @@ public class BoshEditorTest { editor.assertHoverContains("cloud_properties", "Describes any IaaS-specific properties for the subnet"); } + @Test public void cloudconfig_dynamic_network_ca() throws Exception { + Editor editor; + + editor = harness.newEditor(LanguageId.BOSH_CLOUD_CONFIG, + "networks:\n" + + "- name: foo\n" + + " type: dynamic\n" + + " <*>" + ); + editor.assertContextualCompletions(PLAIN_COMPLETION, + "<*>" + , // ==> + "cloud_properties:\n" + + " <*>" + , + "dns:\n" + + " - <*>" + , + "subnets:\n" + + " - <*>" + ); + } + + @Test public void cloudconfig_dynamic_network_mutex_props_reconcile() throws Exception { + //There are essentially two alternate schemas for dynamic NW config. Because we have simply unified them into one (merged all properties)... + // some properties can not be used together because they belong to different sub-schemas. + Editor editor = harness.newEditor(LanguageId.BOSH_CLOUD_CONFIG, + "networks:\n" + + "- name: foo\n" + + " type: dynamic\n" + + " dns: []\n" + + " cloud_properties: {}\n" + + " subnets: []" + ); + editor.ignoreProblem(YamlSchemaProblems.MISSING_PROPERTY); + editor.assertProblems( + "dns|Only one of 'dns' and 'subnets' should be defined", + "cloud_properties|Only one of 'cloud_properties' and 'subnets' should be defined" + ); + } + + @Test public void cloudconfig_dynamic_network_hovers() throws Exception { + Editor editor = harness.newEditor(LanguageId.BOSH_CLOUD_CONFIG, + "networks:\n" + + "- name: foo\n" + + " type: dynamic\n" + + " dns: []\n" + + " cloud_properties: {}\n" + ); + editor.assertHoverContains("name", "Name used to reference this network configuration"); + editor.assertHoverContains("type", "The type of configuration"); + editor.assertHoverContains("dns", "DNS IP addresses for this network"); + editor.assertHoverContains("cloud_properties", "Describes any IaaS-specific properties for the network"); + + editor = harness.newEditor(LanguageId.BOSH_CLOUD_CONFIG, + "networks:\n" + + "- name: my-network\n" + + " type: dynamic\n" + + " subnets:\n" + + " - az: z1\n" + + " dns: []\n" + + " cloud_properties: {subnet: subnet-9be6c3f7}\n" + + " - azs: [z2, z3]\n" + + " cloud_properties: {subnet: subnet-9be6c384}" + ); + editor.assertHoverContains("name", "Name used to reference this network configuration"); + editor.assertHoverContains("type", "The type of configuration"); + editor.assertHoverContains("subnets", "Lists subnets in this network"); + editor.assertHoverContains("dns", "DNS IP addresses for this subnet"); + editor.assertHoverContains("az", "AZ associated with this subnet"); + editor.assertHoverContains("cloud_properties", "Describes any IaaS-specific properties for the subnet"); + editor.assertHoverContains("azs", "List of AZs associated with this subnet"); + } + }