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

Feature: Expand envrionment variables on secrets #824

Merged
merged 6 commits into from
Jul 16, 2023

Conversation

veimox
Copy link
Contributor

@veimox veimox commented Jul 1, 2023

Why

Better developer experience

What

Nx expands environment variables by default when placed in the project.json. For example,

{
...
"publish": {
      "executor": "@nx-tools/nx-container:build",
      "options": {
        ...
        "build-args": [
          "NPM_TOKEN=${NPM_TOKEN}"
        ],
        ...
      }
    },
...
}

will successfuly pass the argument to the image with the expanded value of the environment variable NPM_TOKEN. However

{
...
"publish": {
      "executor": "@nx-tools/nx-container:build",
      "options": {
        ...
        "secrets": [
          "NPM_TOKEN=${NPM_TOKEN}"
        ],
        ...
      }
    },
...
}

will not. This is because the code right now uses that literal string.

This PR expands the environment variables to provide the implicit developer experience. It will likely takcle issues like #595 where people seem confused regarding this feature. Today we provide examples on how to do this, but only works on CI where value is passed already expanded with the INPUT_ env var like in #650

How

Adds a small function to expand the vars and makes use of it both in dockerx and podman

@veimox veimox requested a review from gperdomor as a code owner July 1, 2023 14:18
@veimox veimox changed the title Feature/secrets expand env vars Feature: Expand envrionment variables on secrets Jul 1, 2023
@gperdomor
Copy link
Owner

Hi @veimox, thank you for this MR...

Only one request 😄 ...

@nx-tools/core already have an interpolate function to handle this cases... please use that function instead expandEnvVars

@veimox
Copy link
Contributor Author

veimox commented Jul 11, 2023

Thanks for the tip @gperdomor, I didn't know of it! I just updated it

@nx-cloud
Copy link

nx-cloud bot commented Jul 12, 2023

☁️ Nx Cloud Report

CI is running/has finished running commands for commit b1c52ae. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this branch


✅ Successfully ran 4 targets

Sent with 💌 from NxCloud.

@gperdomor gperdomor merged commit 1c4df14 into gperdomor:main Jul 16, 2023
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants