@@ -69,7 +69,18 @@ Extended service yaml definition is cloned into a plain new yaml subtree then
6969the local service definition is merged as an override. This includes support
7070for `!reset` to remove an element from original service definition.
7171
72- # Phase 7: merge overrides
72+ # Phase 7: include resources from another compose model
73+
74+ A compose file can use `include` to rely on compose resources defined by third-parties
75+ as a separate compose file
76+
77+ Included compose definition is fully parsed (as described in this document) then included
78+ to the compose yaml model being processed. Conflicting resources are detected and rejected
79+
80+ The resulting compose model is equivalent to a copy/paste of the included compose model
81+ (fully resolved) into the local compose file.
82+
83+ # Phase 8: merge overrides
7384
7485If loaded document is an override, the yaml tree is merged with the one from
7586main compose file. `!reset` can be used to remove elements.
@@ -81,15 +92,31 @@ few exceptions:
8192- Attributes which can be expressed both as a mapping and a sequence are converted
8293 so that merge can apply on equivalent data structures.
8394
84- # Phase 8 : enforce unicity
95+ # Phase 9 : enforce unicity
8596
8697While modeled as a list, some attributes actually require some unicity to be
8798applied. Volume mount definition for a service typically must be unique
8899regarding the target mount path. As such attribute can be defined as a single
89100string and set by a variable, we have to apply the "_append to list_" merge
90101strategy then check for unicity.
91102
92- # Phase 9: transform into canonical representation
103+ # Phase 10: validation
104+
105+ During the loading process, some logical rules are checked. But some involved
106+ relations between exclusive attributes, and must be checked as a dedicated phase.
107+
108+ A typical example is the use of `external` in a resource definition. As such a
109+ resource is not managed by Compose, having some resource creation attributes set
110+ must result into an error being reported to the user
111+
112+ ` ` ` yaml
113+ networks:
114+ foo:
115+ external: true
116+ driver: macvlan # This will trigger an error, as external network should not have any resource creation parameter set
117+ ` ` `
118+
119+ # Phase 11: transform into canonical representation
93120
94121Compose specification allows many attribute to have both a "short" and a "long"
95122syntax. It also supports use of single string or list of strings for some
@@ -100,29 +127,13 @@ During loading, all those attributes are transformed into canonical
100127representation, so that we get a single format that will match to go structs
101128for binding.
102129
103- # Phase 10 : extensions
130+ # Phase 12 : extensions
104131
105132Extension (`x-*` attributes) can be used in any place in the yaml document.
106133To make unmarshalling easier, parsing move them all into a custom `#extension`
107134attribute. This hack is very specific to the go binding.
108135
109- # Phase 11: validation
110-
111- During the loading process, some logical rules are checked. But some involved
112- relations between exclusive attributes, and must be checked as a dedicated phase.
113-
114- A typical example is the use of `external` in a resource definition. As such a
115- resource is not managed by Compose, having some resource creation attributes set
116- must result into an error being reported to the user
117-
118- ` ` ` yaml
119- networks:
120- foo:
121- external: true
122- driver: macvlan # This will trigger an error, as external network should not have any resource creation parameter set
123- ` ` `
124-
125- # Phase 12: relative paths
136+ # Phase 13: relative paths
126137
127138Compose allows paths to be set relative to the project directory. Those get resolved
128139into absolute paths during this phase. This involves a few corner cases, as
@@ -141,7 +152,7 @@ volumes:
141152 device: './data' # such a relative path must be resolved
142153` ` `
143154
144- # Phase 13 : go binding
155+ # Phase 14 : go binding
145156
146157Eventually, the yaml tree can be unmarshalled into go structs. We rely on
147158[mapstructure](https://github.com/mitchellh/mapstructure) library for this purpose.
0 commit comments