-
Notifications
You must be signed in to change notification settings - Fork 771
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support nested resources with lexical scoping #1363
Labels
Comments
rynowak
added a commit
to rynowak/bicep
that referenced
this issue
Feb 10, 2021
In progress for Azure#1363 This is an early preview of the work for allowing lexical scoping (nesting) of child resources. This changeset doesn't totally match the current proposal. It will need to be updated based on decisions tracker there and the loops/scoping work that is happening right now.
Team Discussion - 02/10/21 & 02/11/21Comments/decisions
Detailed discussion / open questionsHow should we reference inner-scoped child resources in the outer scope?We discussed a number of options for referring to a child resource in an outer scope. Given the below: resource myParent 'My.Rp/parent@2020-01-01' = {
name: 'parent'
resource myChild 'child' = {
name: 'child'
}
} Some options we considered:
It's important to consider how all of these proposals would work with loops - e.g. We would like community feedback on this, as it's largely a question of personal preference. Some alternatives we dismissed:
What is compatibility like with the current child resource declaration syntax, and the proposed
|
rynowak
added a commit
to rynowak/bicep
that referenced
this issue
Feb 16, 2021
In progress for Azure#1363 This is an early preview of the work for allowing lexical scoping (nesting) of child resources. This changeset doesn't totally match the current proposal. It will need to be updated based on decisions tracker there and the loops/scoping work that is happening right now.
rynowak
added a commit
to rynowak/bicep
that referenced
this issue
Feb 16, 2021
In progress for Azure#1363 This change add support for lexical scoping/nesting of child resources. That it, for a resource type: `My.RP/someType@2020-01-01` there's now a simplified syntax for including a resource: `My.RP/someType/childType@2020-01-01` inside the body of the parent. This syntax also allows simplication of the type name of the child, limits its scope/visibility and implies an automatic `dependsOn` to the parent resource. The goal is to be the most idiomatic way to declare multiple resources to be deployed with a parent/child/grandchild/etc relationship. This is a mostly feature complete implementation of the proposal at issue Azure#1363.
rynowak
added a commit
to rynowak/bicep
that referenced
this issue
Feb 16, 2021
In progress for Azure#1363 This change add support for lexical scoping/nesting of child resources. That it, for a resource type: `My.RP/someType@2020-01-01` there's now a simplified syntax for including a resource: `My.RP/someType/childType@2020-01-01` inside the body of the parent. This syntax also allows simplication of the type name of the child, limits its scope/visibility and implies an automatic `dependsOn` to the parent resource. The goal is to be the most idiomatic way to declare multiple resources to be deployed with a parent/child/grandchild/etc relationship. This is a mostly feature complete implementation of the proposal at issue Azure#1363.
rynowak
added a commit
to rynowak/bicep
that referenced
this issue
Feb 16, 2021
In progress for Azure#1363 This change add support for lexical scoping/nesting of child resources. That it, for a resource type: `My.RP/someType@2020-01-01` there's now a simplified syntax for including a resource: `My.RP/someType/childType@2020-01-01` inside the body of the parent. This syntax also allows simplication of the type name of the child, limits its scope/visibility and implies an automatic `dependsOn` to the parent resource. The goal is to be the most idiomatic way to declare multiple resources to be deployed with a parent/child/grandchild/etc relationship. This is a mostly feature complete implementation of the proposal at issue Azure#1363.
rynowak
added a commit
to rynowak/bicep
that referenced
this issue
Feb 21, 2021
Fixes: Azure#1363 This change add support for lexical scoping/nesting of child resources. That it, for a resource type: `My.RP/someType@2020-01-01` there's now a simplified syntax for including a resource: `My.RP/someType/childType@2020-01-01` inside the body of the parent. This syntax also allows simplication of the type name of the child, limits its scope/visibility and implies an automatic `dependsOn` to the parent resource. The goal is to be the most idiomatic way to declare multiple resources to be deployed with a parent/child/grandchild/etc relationship. This also includes the new "nested resource access" operator which allows lookup of a nested resource: ``` output someOutput string = parent:child.properties.size ``
rynowak
added a commit
to rynowak/bicep
that referenced
this issue
Feb 28, 2021
Fixes: Azure#1363 This change add support for lexical scoping/nesting of child resources. That it, for a resource type: `My.RP/someType@2020-01-01` there's now a simplified syntax for including a resource: `My.RP/someType/childType@2020-01-01` inside the body of the parent. This syntax also allows simplication of the type name of the child, limits its scope/visibility and implies an automatic `dependsOn` to the parent resource. The goal is to be the most idiomatic way to declare multiple resources to be deployed with a parent/child/grandchild/etc relationship. This also includes the new "nested resource access" operator which allows lookup of a nested resource: ``` output someOutput string = parent:child.properties.size ``
rynowak
added a commit
to rynowak/bicep
that referenced
this issue
Feb 28, 2021
Fixes: Azure#1363 This change add support for lexical scoping/nesting of child resources. That it, for a resource type: `My.RP/someType@2020-01-01` there's now a simplified syntax for including a resource: `My.RP/someType/childType@2020-01-01` inside the body of the parent. This syntax also allows simplication of the type name of the child, limits its scope/visibility and implies an automatic `dependsOn` to the parent resource. The goal is to be the most idiomatic way to declare multiple resources to be deployed with a parent/child/grandchild/etc relationship. This also includes the new "nested resource access" operator which allows lookup of a nested resource: ``` output someOutput string = parent:child.properties.size ``
rynowak
added a commit
to rynowak/bicep
that referenced
this issue
Mar 1, 2021
Fixes: Azure#1363 This change add support for lexical scoping/nesting of child resources. That it, for a resource type: `My.RP/someType@2020-01-01` there's now a simplified syntax for including a resource: `My.RP/someType/childType@2020-01-01` inside the body of the parent. This syntax also allows simplication of the type name of the child, limits its scope/visibility and implies an automatic `dependsOn` to the parent resource. The goal is to be the most idiomatic way to declare multiple resources to be deployed with a parent/child/grandchild/etc relationship. This also includes the new "nested resource access" operator which allows lookup of a nested resource: ``` output someOutput string = parent:child.properties.size ``
rynowak
added a commit
to rynowak/bicep
that referenced
this issue
Mar 1, 2021
Fixes: Azure#1363 This change add support for lexical scoping/nesting of child resources. That it, for a resource type: `My.RP/someType@2020-01-01` there's now a simplified syntax for including a resource: `My.RP/someType/childType@2020-01-01` inside the body of the parent. This syntax also allows simplication of the type name of the child, limits its scope/visibility and implies an automatic `dependsOn` to the parent resource. The goal is to be the most idiomatic way to declare multiple resources to be deployed with a parent/child/grandchild/etc relationship. This also includes the new "nested resource access" operator which allows lookup of a nested resource: ``` output someOutput string = parent:child.properties.size ``
rynowak
added a commit
to rynowak/bicep
that referenced
this issue
Mar 1, 2021
Fixes: Azure#1363 This change add support for lexical scoping/nesting of child resources. That it, for a resource type: `My.RP/someType@2020-01-01` there's now a simplified syntax for including a resource: `My.RP/someType/childType@2020-01-01` inside the body of the parent. This syntax also allows simplication of the type name of the child, limits its scope/visibility and implies an automatic `dependsOn` to the parent resource. The goal is to be the most idiomatic way to declare multiple resources to be deployed with a parent/child/grandchild/etc relationship. This also includes the new "nested resource access" operator which allows lookup of a nested resource: ``` output someOutput string = parent:child.properties.size ``
rynowak
added a commit
to rynowak/bicep
that referenced
this issue
Mar 1, 2021
Fixes: Azure#1363 This change add support for lexical scoping/nesting of child resources. That it, for a resource type: `My.RP/someType@2020-01-01` there's now a simplified syntax for including a resource: `My.RP/someType/childType@2020-01-01` inside the body of the parent. This syntax also allows simplication of the type name of the child, limits its scope/visibility and implies an automatic `dependsOn` to the parent resource. The goal is to be the most idiomatic way to declare multiple resources to be deployed with a parent/child/grandchild/etc relationship. This also includes the new "nested resource access" operator which allows lookup of a nested resource: ``` output someOutput string = parent:child.properties.size ``
rynowak
added a commit
to rynowak/bicep
that referenced
this issue
Mar 1, 2021
Fixes: Azure#1363 This change add support for lexical scoping/nesting of child resources. That it, for a resource type: `My.RP/someType@2020-01-01` there's now a simplified syntax for including a resource: `My.RP/someType/childType@2020-01-01` inside the body of the parent. This syntax also allows simplication of the type name of the child, limits its scope/visibility and implies an automatic `dependsOn` to the parent resource. The goal is to be the most idiomatic way to declare multiple resources to be deployed with a parent/child/grandchild/etc relationship. This also includes the new "nested resource access" operator which allows lookup of a nested resource: ``` output someOutput string = parent:child.properties.size ``
rynowak
added a commit
to rynowak/bicep
that referenced
this issue
Mar 1, 2021
Fixes: Azure#1363 This change add support for lexical scoping/nesting of child resources. That it, for a resource type: `My.RP/someType@2020-01-01` there's now a simplified syntax for including a resource: `My.RP/someType/childType@2020-01-01` inside the body of the parent. This syntax also allows simplication of the type name of the child, limits its scope/visibility and implies an automatic `dependsOn` to the parent resource. The goal is to be the most idiomatic way to declare multiple resources to be deployed with a parent/child/grandchild/etc relationship. This also includes the new "nested resource access" operator which allows lookup of a nested resource: ``` output someOutput string = parent:child.properties.size ``
rynowak
added a commit
to rynowak/bicep
that referenced
this issue
Mar 1, 2021
Fixes: Azure#1363 This change add support for lexical scoping/nesting of child resources. That it, for a resource type: `My.RP/someType@2020-01-01` there's now a simplified syntax for including a resource: `My.RP/someType/childType@2020-01-01` inside the body of the parent. This syntax also allows simplication of the type name of the child, limits its scope/visibility and implies an automatic `dependsOn` to the parent resource. The goal is to be the most idiomatic way to declare multiple resources to be deployed with a parent/child/grandchild/etc relationship. This also includes the new "nested resource access" operator which allows lookup of a nested resource: ``` output someOutput string = parent:child.properties.size ``
rynowak
added a commit
to rynowak/bicep
that referenced
this issue
Mar 2, 2021
Fixes: Azure#1363 This change add support for lexical scoping/nesting of child resources. That it, for a resource type: `My.RP/someType@2020-01-01` there's now a simplified syntax for including a resource: `My.RP/someType/childType@2020-01-01` inside the body of the parent. This syntax also allows simplication of the type name of the child, limits its scope/visibility and implies an automatic `dependsOn` to the parent resource. The goal is to be the most idiomatic way to declare multiple resources to be deployed with a parent/child/grandchild/etc relationship. This also includes the new "nested resource access" operator which allows lookup of a nested resource: ``` output someOutput string = parent:child.properties.size ``
rynowak
added a commit
to rynowak/bicep
that referenced
this issue
Mar 3, 2021
Fixes: Azure#1363 This change add support for lexical scoping/nesting of child resources. That it, for a resource type: `My.RP/someType@2020-01-01` there's now a simplified syntax for including a resource: `My.RP/someType/childType@2020-01-01` inside the body of the parent. This syntax also allows simplication of the type name of the child, limits its scope/visibility and implies an automatic `dependsOn` to the parent resource. The goal is to be the most idiomatic way to declare multiple resources to be deployed with a parent/child/grandchild/etc relationship. This also includes the new "nested resource access" operator which allows lookup of a nested resource: ``` output someOutput string = parent:child.properties.size ``
rynowak
added a commit
to rynowak/bicep
that referenced
this issue
Mar 4, 2021
Fixes: Azure#1363 This change add support for lexical scoping/nesting of child resources. That it, for a resource type: `My.RP/someType@2020-01-01` there's now a simplified syntax for including a resource: `My.RP/someType/childType@2020-01-01` inside the body of the parent. This syntax also allows simplication of the type name of the child, limits its scope/visibility and implies an automatic `dependsOn` to the parent resource. The goal is to be the most idiomatic way to declare multiple resources to be deployed with a parent/child/grandchild/etc relationship. This also includes the new "nested resource access" operator which allows lookup of a nested resource: ``` output someOutput string = parent:child.properties.size ``
rynowak
added a commit
to rynowak/bicep
that referenced
this issue
Mar 4, 2021
Fixes: Azure#1363 This change add support for lexical scoping/nesting of child resources. That it, for a resource type: `My.RP/someType@2020-01-01` there's now a simplified syntax for including a resource: `My.RP/someType/childType@2020-01-01` inside the body of the parent. This syntax also allows simplication of the type name of the child, limits its scope/visibility and implies an automatic `dependsOn` to the parent resource. The goal is to be the most idiomatic way to declare multiple resources to be deployed with a parent/child/grandchild/etc relationship. This also includes the new "nested resource access" operator which allows lookup of a nested resource: ``` output someOutput string = parent:child.properties.size ``
rynowak
added a commit
to rynowak/bicep
that referenced
this issue
Mar 6, 2021
Fixes: Azure#1363 This change add support for lexical scoping/nesting of child resources. That it, for a resource type: `My.RP/someType@2020-01-01` there's now a simplified syntax for including a resource: `My.RP/someType/childType@2020-01-01` inside the body of the parent. This syntax also allows simplication of the type name of the child, limits its scope/visibility and implies an automatic `dependsOn` to the parent resource. The goal is to be the most idiomatic way to declare multiple resources to be deployed with a parent/child/grandchild/etc relationship. This also includes the new "nested resource access" operator which allows lookup of a nested resource: ``` output someOutput string = parent:child.properties.size ``
majastrz
pushed a commit
that referenced
this issue
Mar 6, 2021
Fixes: #1363 This change add support for lexical scoping/nesting of child resources. That it, for a resource type: `My.RP/someType@2020-01-01` there's now a simplified syntax for including a resource: `My.RP/someType/childType@2020-01-01` inside the body of the parent. This syntax also allows simplication of the type name of the child, limits its scope/visibility and implies an automatic `dependsOn` to the parent resource. The goal is to be the most idiomatic way to declare multiple resources to be deployed with a parent/child/grandchild/etc relationship. This also includes the new "nested resource access" operator which allows lookup of a nested resource: ``` output someOutput string = parent:child.properties.size ``
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
Is your feature request related to a problem? Please describe.
Specifying parent/child relationships can be confusing and verbose. You can also end up in situations where the child doesn't reference the parent and so have nothing to add
dependsOn
for you.Describe the solution you'd like
The ability to nest resource definitions such that parent/child relationships are generated for you.
Child resources would be allowed to appear at the top level of nesting inside another resource. I'm showing the child resource as indented here, but there's no requirement that it be aligned, only that it doesn't appear inside a nested object definition.
The examples here assume the answers to some of the questions that are still being discussed
Overview
The proposal allows the following simplifications in how these cases are written:
name
property can be simplified because it must contain the parent's namedependsOn
the parent for creation-order purposesif
conditions can be omitted for child resources in this formThis proposal augments other proposals (like adding a
parent
property). The nested form of resource declarations can be seen as an opinionated combination of other features, like.parent
.Open Questions
Parsing
With this proposal, resources may directly contain other resources. This must be at the top level - not nested inside an object declaration.
OK
Error
Lexically-nested resources my appear interspersed with other properties:
OK
Rationale: It doesn't really make sense to block this. We might think that the middle case from above is ugly, but if we allow the first and last case it makes sense to allow the middle one.
Scoping
Lexically nested resources declare names that are within the scope of their parent resource. There's a discussion happening right now about to refer to such resources. For the purpose of examples, I'm filling in the
a/b/c
syntax.OK
Error
Type System
I suspect some of this will require debate and discussion, see open questions.
Within a resource, the nested types must be child types of the containing (parent) resource. Type names use a simplified format, and must refer to a single type segment. The API Version is optional, and will be assumed to match the parent if unspecified.
OK
Error
Rationale:
If we allow simplified (relative) type names and qualified type names then we have to be able to tell the difference between them. This is entangled with the decision to allow/ban mutli-generational nesting (directly containing a grandchild resource).
If we allow directly nesting a grandchild resource then the question of how do know the parent? becomes necessary to answer. We're automatically generating the full name of the resource, and injecting an
dependsOn
entry, so we need to know how to refer to the parent. We could choose to relax this restriction in the future by requiring the.parent
property to be set, but that seems unnecessary since you can fall back to the more complex form, or use anexisting
reference to the parent as better options - remember this is about directly nesting a multi-generation relationship.Now let's return to how type names are written:
ChildType
vsSome.Resource/Type/ChildType
then the task is simpleSome.Resource/Type
vsChildType/GrandChildType
- so allowing either of these constrains our ability to relax limitations in the futureFor a nested resource, the
.parent
property is considered to be readonly.Error
The lexical nesting has the same semantic effect as setting the parent, so we should not allow it to be manually set and cause a conflict by setting a different value.
Semantics and Codegen
The child resources are assumed to have an implement
dependsOn
to the parent. The cycle checker in the compiler will be made aware of this as well.Error
Loops and conditions on the parent resource carry:
Existing has little overlap with the semantics here since nesting of resources just creates a reference. It 'just works'.
The text was updated successfully, but these errors were encountered: