Skip to content

refactored to rely on yaml.Node during parsing#854

Draft
ndeloof wants to merge 3 commits intocompose-spec:mainfrom
ndeloof:yaml.Node
Draft

refactored to rely on yaml.Node during parsing#854
ndeloof wants to merge 3 commits intocompose-spec:mainfrom
ndeloof:yaml.Node

Conversation

@ndeloof
Copy link
Copy Markdown
Collaborator

@ndeloof ndeloof commented Mar 13, 2026

The existing compose file loading pipeline uses map[string]any as its intermediate representation, which loses YAML source location information (file, line number). This makes it impossible to produce precise error messages pointing to the offending line in the source file.

It also forces interpolation and path resolution to happen eagerly, with a single global environment, even though include directives can specify per-file env_file and project_directory.

This PR introduces a new loading path to build a ComposeModel backed by raw *yaml.Node trees. Each node is associated with a NodeContext that captures the environment variables, working directory, and source filename from its originating file. All normalization (interpolation, type casting, path resolution) is deferred until Resolve() is called.

This also allows to get rid of mapstructure dependency an rely on UnmarshallYAML function to cover type conversions

** Do not merge**
this PR is a WiP until it is fully tested with Docker Compose to ensure compatibility, then go.mod version will be bumped to v3.

@ndeloof ndeloof force-pushed the yaml.Node branch 5 times, most recently from 855edb9 to 338f67b Compare March 15, 2026 16:55
@ndeloof ndeloof marked this pull request as ready for review March 18, 2026 14:58
@ndeloof ndeloof requested a review from glours March 18, 2026 15:00
@ndeloof ndeloof marked this pull request as draft March 23, 2026 14:52
ndeloof added 2 commits March 24, 2026 07:31
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
@ndeloof ndeloof force-pushed the yaml.Node branch 2 times, most recently from 90b37ec to c100299 Compare March 24, 2026 07:05
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant