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

Fix required env vars ignored except the last one

Open rimelek opened this issue 2 years ago • 0 comments

During the variable substitution, if a missing variable was followed by an existing one, the empty "err" variable overwrote the previous non-empty variable.

Unlike with Docker Compose v1, the first found error did not guarantee that an actual error would be thrown.

Example which would have run before the fix even though var1 is not defined:

services:
  bash:
    image: bash:5.0.18-alpine3.15
    environment:
      var12: "_ ${var1:?Error1} _ ${var2:?Error2} _ "
    command:
      - env
# var2=1 docker compose up

This change also means that, if multiple variables are missing in one string, the first one will be reported by Docker Compose

Signed-off-by: Ákos Takács [email protected]

rimelek avatar Mar 20 '22 17:03 rimelek