feat: Add ability to mount secrets #487
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 thecopy
andcontainerfile
modules.Supported methods
Environment Variables
You can specify an environment variable to mount from the host.
Files
You can specify a file on the host machine and where to mount it in the build.
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)
SSH
You can also mount your SSH socket. This is useful when you want to checkout something from a private git repo.