docker/compose loads the full project just to resolve the project name
for runtime commands (exec, ps, logs, ...) and uses
WithoutEnvironmentResolution so a missing env_file on an unrelated
service does not abort them. label_file resolution had no equivalent
opt-out: WithServicesLabelsResolved ran unconditionally and failed on
any missing file (label_file variant of docker/compose#13601).
Gate it behind loader.Options.SkipResolveLabels and expose
cli.WithoutLabelsResolution.
Also stop discarding label_file entries when WithDiscardEnvFiles is
set: since 56297d8 the loader passed the env_file discard flag into
label resolution, silently dropping label_file entries too. Discard is
only meant for env_file.
Signed-off-by: Guillaume Lours <glours@users.noreply.github.com>
There were cases where the loader would infer a perfectly valid
project name by normalizing a directory, but would then re-validate
the un-normalized project directory and throw an error.
This moves all the validation into a single spot during the load,
which is the only point that it has all the context.
Some of this logic needs to be pushed out of here: it should NOT
be reading the config files, for example.
For now, this resolves the main issues.
Signed-off-by: Milas Bowman <milas.bowman@docker.com>