-
Notifications
You must be signed in to change notification settings - Fork 0
Introduce named mappings to model loading, with properly implemented interpolate after merge #3
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
base: vigilans/named-mappings-model-resolver
Are you sure you want to change the base?
Conversation
…l dict's fields Signed-off-by: Vigilans <[email protected]>
* `mergeExtraHosts` is removed and splited into `mergeToSequence` + `extraHostsIndexer` Signed-off-by: Vigilans <[email protected]>
…esult Signed-off-by: Vigilans <[email protected]>
…e`, `OmitEmpty` and `ResolveEnvironment` process Signed-off-by: Vigilans <[email protected]>
…field's working dir at specific path Signed-off-by: Vigilans <[email protected]>
…ay traversal * Implemented match logic for `tree.PathMatchAll` Signed-off-by: Vigilans <[email protected]>
…d-aware working dirs for path resolution * Integrates `utils.Pair` into `ApplyExtends` and `ApplyInclude` * `ApplyExtends` and `ApplyInclude` will now use absolute working dir, instead of relative dir to the upper extends/include stack Signed-off-by: Vigilans <[email protected]>
* `transform.transformVolumeMount` relies on volume string interpolated to correctly parse, therefore need to run after interpolate Signed-off-by: Vigilans <[email protected]>
* Filename is retrieved by looking up field's source config file by error's deriving field path Signed-off-by: Vigilans <[email protected]>
* `include.*.env_file` is supported with `interpolate.Options.LookupValueMapping` Signed-off-by: Vigilans <[email protected]>
* Testcases picked from docker/compose#12001, docker/compose#11990 Signed-off-by: Vigilans <[email protected]>
* `env` and `project` named mappings are moved to `ResolveGlobal` Signed-off-by: Vigilans <[email protected]>
Signed-off-by: Vigilans <[email protected]>
* `project[name]` and `project[working-dir]` is fixed to take `include` into account Signed-off-by: Vigilans <[email protected]>
Signed-off-by: Vigilans <[email protected]>
e9e086e to
b1a7b06
Compare
3014b5f to
e0f6ab6
Compare
|
We already tried to introduce "interpolate after merge" but this always introduced regressions one way or the other 😓 |
Yes, I've already seen your past effort in docker/compose#11925 (comment) and compose-spec#666 (comment)... I've added all regressions introduced in last attempt as test in commit cde7729, to ensure my attempt will not cause past regressions once more... |
This PR adds support for named mappings to
loaderpackage's model loading process, with properly implementedinterpolate after mergemechanism.Embed model fields with contexts
Since compose has complex mechanisms for dealing with multiple configurations files:
-fIt would be difficult to know in final merged dict that a specific field derives from which config file.
To solves this issue, a new concept is introduced: Embed each field of model dict with a context, and let the contexts participate into computations (
Merge,Canonical, etc.) with fields. After all computations are done, unwrap the contexts from the dict, then we can answer questions likewhich config is this field from?giving any specific field.Run interpolate after merge
Interpolation is now run after the final merged dict is ready, to retrieve correct and thorough information when resolving.
It is properly implemented with the help of embedded contexts, to retain scope information of each field, so variables like
${project[working-dir]},${compose[config-dir]}can return correctly value.Some operations is dependent on the interpolated value, like
transform.transformVolumeMountinCanonical,gojsonschema.Validate, they're also moved out to run after interpolation (thus after merge).ResolveGlobalmethod for Resolver interfaceA new method,
ResolveGlobal(ctx, opts), is introduced inNamedMappingsResolverinterface. It is run before model dict is even available, to provide information that can be known at global level, likeenv,projectmappings. So partial interpolation can happen duringextendsandinclude.Related Issues