Flatten embedded `properties`.
- Dominant language
- Bicep
- Stars
- 3.6k
- Forks
- 830
- Avg merge
- 1d 21m
- Merged PRs (30d)
- 79
Description
Do we need to have explicit `properties`, or could these be flattened? Would there ever be a clash between property names and top level values such as 'kind', `identity`, etc.? Could embedded types be flattened with some intelligence of the resources?
There are some resources with very embedded types with properties. See for example this definition for a network profile for connecting ACI to a virtual network. That's a lot of brackets! Also there are three levels of embedded `properties`, yet there is only one single value being set here; the subnet id.
```
resource aciNetProfile 'Microsoft.Network/networkProfiles@2020-05-01' = {
name: 'acinetworkprofile'
location: location
properties: {
containerNetworkInterfaceConfigurations: [
{
name: 'aci-nic'
properties: {
ipConfigurations: [
{
name: 'nicipconfig'
properties: {
subnet: {
id: network.properties.subnets[3].id
}
}
}
]
}
}
]
}
}
```
Would it be possible to massively simplify certain situations like this with a bit of knowledge about RPs?
Could we do something like
```
resource mycontainer 'Microsoft.ContainerInstance/containerGroups@2019-12-01' = {
name: 'mycontainer'
location: location
properties: {
networkProfile: network.properties.subnets[3]
...
```
and have Bicep know that this means it needs to create the `networkProfile`, `containerNetworkInterfaceConfigurations` and `ipConfigurations` in the generated ARM template?
Contributor guide
Research direction
Start with the network profile example and the proposed container-group syntax in this issue; compare the desired shorthand with the corresponding generated ARM template shape. Done would require a decided flattening model that handles nested properties and name clashes, plus agreement on how RP-specific knowledge is supplied.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- json
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100