Skip to content

Conversation

gmpinder
Copy link
Member

@gmpinder gmpinder commented Jul 13, 2025

This MR implements the use of secrets for use in module calls. It will handle securely mounting secrets via generating a unique hash for each secret and is unique for each build that will be used as its ID and mount path unless otherwise specified by the user.

NOTE: The examples below make use of the script module to show that secrets do get mounted. This feature is available for every module except the copy and containerfile modules.

Supported methods

Environment Variables

You can specify an environment variable to mount from the host.

type: script
secrets:
  - type: env
    name: TEST_SECRET
snippets:
  - echo "The test secret is $TEST_SECRET"

Files

You can specify a file on the host machine and where to mount it in the build.

type: script
secrets:
  - type: file
    source: /path/to/secret
    destination: /tmp/secrets/test-secret
snippets:
  - echo "The test secret is $(cat /tmp/secrets/test-secret)"

Commands

You can also run a command on the host machine to read the secret from stdout. This is useful if you have some external secrets provider like Vault or Bitwarden. You can also specify if the value should be mounted as a file or as an environment variable.

Secrets generated from external commands are stored in a temp file on the host that is cleaned up after the build completes. (see: tempfile) Secrets stored in memory are zeroized when dropped. (see: zeroize)

type: script
secrets:
  - type: exec
    command: vault
    args:
      - kv
      - get
      - secretes/test/secret
    output:
      type: env
      name: TEST_SECRET
snippets:
  - echo "The test secret is $TEST_SECRET"

SSH

You can also mount your SSH socket. This is useful when you want to checkout something from a private git repo.

type: script
secrets:
  - type: ssh
snippets:
  - git clone [email protected]:user/private_repo.git

@gmpinder gmpinder self-assigned this Jul 13, 2025
@gmpinder gmpinder linked an issue Jul 13, 2025 that may be closed by this pull request
@gmpinder gmpinder force-pushed the 434-feat-allow-mounting-of-secrets-for-build-steps branch 4 times, most recently from f83b6ea to 7ff35d9 Compare July 13, 2025 17:45
@gmpinder gmpinder marked this pull request as ready for review July 13, 2025 18:08
@gmpinder gmpinder force-pushed the 434-feat-allow-mounting-of-secrets-for-build-steps branch 7 times, most recently from 33f7474 to ea18dd3 Compare July 14, 2025 23:08
@gmpinder gmpinder force-pushed the 434-feat-allow-mounting-of-secrets-for-build-steps branch from ea18dd3 to f2da712 Compare July 16, 2025 12:33
@gmpinder gmpinder merged commit 4fabd3e into main Jul 17, 2025
31 of 34 checks passed
@gmpinder gmpinder deleted the 434-feat-allow-mounting-of-secrets-for-build-steps branch July 17, 2025 18:03
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.

feat: Allow mounting of secrets for build steps
1 participant