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

environment variables cannot be escaped in the compose file #3394

Open
AdrianPedriza opened this issue Feb 17, 2023 · 3 comments
Open

environment variables cannot be escaped in the compose file #3394

AdrianPedriza opened this issue Feb 17, 2023 · 3 comments
Labels
bug Something isn't working keep

Comments

@AdrianPedriza
Copy link
Contributor

AdrianPedriza commented Feb 17, 2023

Describe the bug
when I try to escape the value of an environment variable as allowed by docker, the escaped value is not reflected in my deployment.

To Reproduce
Steps to reproduce the behavior:

(Using docker compose)

  1. create a compose file
services:
  servicea:
      image: nginx
      environment:
        TESTA: $${myenv}
        TESTB: avalue
  1. Run docker-compose up
  2. See envs in container (docker exec <container-id> /usr/bin/env) contains escaped value:

Captura de pantalla 2023-02-17 a las 11 24 17

(using okteto)

  1. Using same compose file, exec okteto deploy -f docker-compose.yml
  2. See envs in pod doesn't contain escaped env

Captura de pantalla 2023-02-17 a las 11 31 56

Expected behavior
I expect a behavior similar to that of docker compose where the escaped variable is correctly added as env

@AdrianPedriza AdrianPedriza added triage bug Something isn't working and removed triage labels Feb 17, 2023
@AgustinRamiroDiaz
Copy link
Contributor

AgustinRamiroDiaz commented Feb 17, 2023

Additional context from my debugging: Seems like we are expanding the envvars twice, because the stack expander is already expanding the envvars and changes the $${envvar} to ${envvar}

expandValue, err := ExpandEnv(node.Value, true)

But at some point in the future we are again expanding the envvars ofw the manifest again

value, err = ExpandEnv(value, true)

and that's where we lose ${envvar} for "" . My intuition tells me we should only do it only in the manifest, but we should see the different behaviors

@teresaromero I remember you've worked with the yaml expander, do you have any idea around this?

@teresaromero
Copy link
Member

@AgustinRamiroDiaz if i recall correctly, the stack expander using the nodes was introduced in order to parse correctly the multiline envs... from that persperctive, if escaped envs are not being correctly expanded,

@AdrianPedriza could we add a unit test to ExpandEnv with this inputs and expected output to trace if the format is correct? sorry i dont remember 100% how this was expanded

@github-actions
Copy link
Contributor

This issue is stale because it has been open for 60 days with no activity. Comment on this issue or it will be closed in 7 days

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working keep
Projects
None yet
Development

No branches or pull requests

3 participants