Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nested variable substitution is unsupported #1064

Open
schuelermine opened this issue Oct 30, 2024 · 0 comments
Open

Nested variable substitution is unsupported #1064

schuelermine opened this issue Oct 30, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@schuelermine
Copy link

schuelermine commented Oct 30, 2024

Describe the bug
Podman compose does not correctly handle variable substitution with default values or error messages that themselves contain variable substitutions.

To Reproduce
Steps to reproduce the behavior:

  1. Use the following sample files:
    • Dockerfile:
      FROM registry.hub.docker.com/library/busybox:1.37.0-glibc
      
      ARG LINE1
      ARG LINE2
      ARG LINE3
      
      RUN <<EOF
      echo ${LINE1}
      echo ${LINE2}
      echo ${LINE3}
      EOF
    • compose.yaml:
      services:
        service:
          build:
            dockerfile: Dockerfile
            args:
              LINE1: "value of $$variable_1: $variable_1"
              LINE2: "value of $$variable_2: $variable_2"
              LINE3: "value of $${variable_1:-$${variable_2}}: ${variable_1:-${variable_2}}"
  2. Run the following commands:
    • variable_1=foo podman compose build
    • variable_2=bar podman compose build

Expected behavior
The output of the third echo should end in:

  • for variable_1=foo: foo
  • for variable_2=bar: bar

Actual behavior
The relevant lines end with:

  • for variable_1=foo: foo}
  • for variable_2=bar: ${variable_2}

Output

$ podman compose version
>>>> Executing external compose provider "/run/current-system/sw/bin/podman-compose". Please see podman-compose(1) for how to disable this message. <<<<

podman-compose version 1.2.0
podman version 5.2.3
$ variable_1=foo podman compose build --no-cache
>>>> Executing external compose provider "/run/current-system/sw/bin/podman-compose". Please see podman-compose(1) for how to disable this message. <<<<

STEP 1/5: FROM registry.hub.docker.com/library/busybox:1.37.0-glibc
STEP 2/5: ARG LINE1
--> 330d7d829840
STEP 3/5: ARG LINE2
--> 4821dfb5862e
STEP 4/5: ARG LINE3
--> b5022f8e7e7f
STEP 5/5: RUN <<EOF (echo ${LINE1}...)
value of $variable_1: foo
value of $variable_2:
value of ${variable_1:-${variable_2}}: foo}
COMMIT goal-tree-rl_service
--> e305b923d654
Successfully tagged localhost/goal-tree-rl_service:latest
e305b923d654d30bacca9c10fb1d01501a799fbe86ceaf6571d0cd187b40e737
$ variable_2=bar podman compose build --no-cache
>>>> Executing external compose provider "/run/current-system/sw/bin/podman-compose". Please see podman-compose(1) for how to disable this message. <<<<

STEP 1/5: FROM registry.hub.docker.com/library/busybox:1.37.0-glibc
STEP 2/5: ARG LINE1
--> c8fbf7102206
STEP 3/5: ARG LINE2
--> c06fd0ab1eec
STEP 4/5: ARG LINE3
--> 3e9b51fe4501
STEP 5/5: RUN <<EOF (echo ${LINE1}...)
value of $variable_1:
value of $variable_2: bar
value of ${variable_1:-${variable_2}}: ${variable_2}
COMMIT goal-tree-rl_service
--> 77bdcc77f708
Successfully tagged localhost/goal-tree-rl_service:latest
77bdcc77f7081eeb79ebb78fbd5e7d6cbb01a2ee13718ef95efd1ff7f62ed684

Environment:

  • OS: NixOS 24.11.20241023.2768c7d (Vicuna), Linux 6.11.5
  • podman version: podman version 5.2.3
  • podman compose version: git ref unknown; displays as 1.2.0

Additional context

Relevant section of Compose file specification: https://github.com/compose-spec/compose-spec/blob/main/12-interpolation.md

@schuelermine schuelermine added the bug Something isn't working label Oct 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant