Skip to content

load: include details about included files on Project#444

Merged
milas merged 1 commit intocompose-spec:masterfrom
milas:load-includes-metadata
Aug 18, 2023
Merged

load: include details about included files on Project#444
milas merged 1 commit intocompose-spec:masterfrom
milas:load-includes-metadata

Conversation

@milas
Copy link
Copy Markdown
Member

@milas milas commented Aug 16, 2023

Add a map to Project that has Compose YAML filename as key and any IncludeConfigs loaded from it.

This is populated as the project is recursively loaded.

For example:

proj/
  compose.yaml
  a/
    compose.yaml
  b/
    compose.yaml

If project/compose.yaml has:

include: ['./a/compose.yaml']

And project/a/compose.yaml has:

include: ['../b/compose.yaml']

The final result after load is conceptually:

{
  "proj/compose.yaml": ["proj/a/compose.yaml"],
  "proj/a/compose.yaml": ["proj/b/compose.yaml"],
}

(Note: in reality, it's a list of IncludeConfig, which has multiple fields. Example is simplified.)

Relative path resolution is based on overall loader configuration, but note that disabling it does not work properly for include currently due to other issues.

This makes it possible for the caller to understand a bit more about the loaded project resources. We're really overdue for a bit of an overhaul/refactor of the loader - at that point, I think it might be better to have a Loader object type that can track stuff like this on the instance because it's weirdly both part of the project and NOT part of the project at the moment (similar to Profiles, project name, etc).

@milas milas added the enhancement New feature or request label Aug 16, 2023
@milas milas requested a review from ndeloof August 16, 2023 17:58
@milas milas self-assigned this Aug 16, 2023
Add a map to `Project` that has Compose YAML filename as key and
any `IncludeConfig`s loaded from it.

This is populated as the project is recursively loaded.

For example:
```
  proj/
    compose.yaml
    a/
      compose.yaml
    b/
      compose.yaml
```

If `project/compose.yaml` has:
```
include: ['./a/compose.yaml']
```

And `project/a/compose.yaml` has:
```
include: ['../b/compose.yaml']
```

The final result after load is conceptually:
```
{
  "proj/compose.yaml": ["proj/a/compose.yaml"],
  "proj/a/compose.yaml": ["proj/b/compose.yaml"],
}
```
(Note: in reality, it's a list of `IncludeConfig`, which has multiple
fields. Example is simplified.)

Relative path resolution is based on overall loader configuration,
but note that disabling it does not work properly for `include`
currently due to other issues.

This makes it possible for the caller to understand a bit more
about the loaded project resources. We're really overdue for a bit
of an overhaul/refactor of the loader - at that point, I think it
might be better to have a `Loader` object type that can track stuff
like this on the instance because it's weirdly both part of the
project and NOT part of the project at the moment (similar to
`Profiles`, project name, etc).

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
@milas milas force-pushed the load-includes-metadata branch from 07c0fc1 to 1af5178 Compare August 16, 2023 18:00
@milas milas merged commit ae43465 into compose-spec:master Aug 18, 2023
@milas milas deleted the load-includes-metadata branch August 18, 2023 13:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants