compose-go icon indicating copy to clipboard operation
compose-go copied to clipboard

feat(loader): made interpolation after merge

Open idsulik opened this issue 1 year ago • 5 comments

What this PR does / why we need it: Changed interpolation order, it used to interpolate for each config file separately, but now it interpolates after merge.
To be honest, I'm not sure it's a good idea, maybe it'll be better to add an option to control it, like --interpolate-after-merge

Which issue(s) this PR fixes: Fixes https://github.com/docker/compose/issues/11925

idsulik avatar Jun 23 '24 08:06 idsulik

This was my initial intent during compose-go/v2 refactoring, but this breaks when include or extends uses variables for target file/service. Need at least partial interpolation for those - I never took time to look into this, would you like to give it a try ?

ndeloof avatar Jun 23 '24 08:06 ndeloof

but this breaks when include or extends uses variables for target file/service

@ndeloof could you please provide an example?

idsulik avatar Jun 23 '24 08:06 idsulik

A typical use:

services:
  prod:
    image: a

  dev:
    image: a-dev

  app:
    extends: ${BASE:-prod}

ndeloof avatar Jun 23 '24 09:06 ndeloof

@ndeloof pushed changes to interpolate include and extends before merging and interpolate everything after the merge, but I think it becomes too complicated.

idsulik avatar Jun 23 '24 10:06 idsulik

Checking this PR again I went with an alternate implementation, reusing your test case: https://github.com/compose-spec/compose-go/pull/651

wdyt ?

Anyway, the current compose-spec schema declare types for many attributes which can actually be set by a variable, and validation fails. Would need to first fix the schema

ndeloof avatar Jul 01 '24 10:07 ndeloof

Closing as https://github.com/compose-spec/compose-go/pull/651 has been merged

ndeloof avatar Jul 08 '24 12:07 ndeloof