Components in a StyleBook can refer to properties or sections of other components in the same StyleBook. Components are complete blocks by themselves and they may not be written in the same order that they have to be executed. The StyleBook compiler checks the order in which the components are written and then executes them in a logical order.
Example:
components:
-
name: lbvserver-comp
type: ns::lbvserver
properties:
name: mylb
ipv46: 10.102.190.15
port: 80
servicetype: HTTP
-
name: lb-sg-binding-comp
type: ns::lbvserver_servicegroup_binding
condition: $parameters.create-binding
properties:
name: $components.lbvserver-comp.properties.name
servicegroupname: $components.sg-comp.properties.servicegroupname
-
name: sg-comp
type: ns::servicegroup
properties:
servicegroupname: mysg
servicetype: HTTP
In the above example, there are three components defined - lbvserver-comp, lb-sg-binding-comp, and sg-comp. When this StyleBook is executed, the lbvserver-comp is first created. The lb-sg-binding-comp refers to lbvserver-comp properties, but it cannot be created next though it is the second component defined in the StyleBook. This is because the lb-sg-binding-comp also has a dependency on the sg-comp which is yet to be created. As a result, the compiler reorders the components so that the dependencies of a component are resolved by the time a component is created, and executes this reordered list of components. The order of execution of the above StyleBook is: lbvserver-comp, sg-comp, and lb-sg-binding-comp.
Thus, the author of a StyleBook need not worry about the correct order of the components. The components may appear in any order. The compiler computes the correct order of execution of the components based on how the components refer each other. Note that this dependency detection and reordering also works for substitutions and outputs sections as well.