Skip to content

Commit

Permalink
Change plugin id
Browse files Browse the repository at this point in the history
Add token file path parameter
  • Loading branch information
maierj committed Jan 5, 2021
1 parent 12093db commit e4de2ce
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .buildkite/linting.pipeline.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
steps:
- label: "Linting"
command: 'docker run -it --rm -v "${PWD}:/plugin:ro" buildkite/plugin-linter --id adabay/vault-key-value'
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Secrets have to be specified by their path and their key.
To authorize the access to Vault, this plugin provides 2 methods:
* Use a preexisting token environment variable (`VAULT_TOKEN`). This could be injected by an agent environment hook for example.
* Use a token that was written to a file. This is the appropriate method to authorize if you use the Vault Agent's auto-auth method to keep a valid token on the build agent.
To use this method, you have to specify the path to the token file using the plugin parameter `token_file_path` or using the environment variable `BUILDKITE_PLUGIN_VAULT_TOKEN_FILE_PATH`.
To use this method, you have to specify the path to the token file using the plugin parameter `token_file_path` or using the environment variable `BUILDKITE_PLUGIN_VAULT_KEY_VALUE_TOKEN_FILE_PATH`.

## Example

Expand Down Expand Up @@ -46,6 +46,10 @@ steps:
## Configuration
### `token_file_path` (string)

Use this parameter to specify the path to the file where the Vault Agent writes the token to. If not specified, the preexisting environment variable `VAULT_TOKEN` is used to authorize requests to Vault.

### `secrets` (array)

If you want to export multiple secrets, you can use this array. Each entry in this array has to have the configuration properties that are listed below.
Expand All @@ -67,5 +71,5 @@ With this parameter you can define the name of the environment variable that you
To run the linter:

```shell
docker run -it --rm -v "${PWD}:/plugin:ro" buildkite/plugin-linter --id adabay/vault
docker run -it --rm -v "${PWD}:/plugin:ro" buildkite/plugin-linter --id adabay/vault-key-value
```
6 changes: 5 additions & 1 deletion hooks/environment
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

set -eo pipefail

export VAULT_TOKEN=$(cat $VAULT_TOKEN_FILE_PATH)
if [[ -z "${BUILDKITE_PLUGIN_VAULT_KEY_VALUE_TOKEN_FILE_PATH}" ]]; then
echo "Using preexisting token from environment variable \"VAULT_TOKEN\""
else
export VAULT_TOKEN="$(cat $BUILDKITE_PLUGIN_VAULT_KEY_VALUE_TOKEN_FILE_PATH)"
fi

secret_paths=()
secret_keys=()
Expand Down
2 changes: 2 additions & 0 deletions plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ configuration:
properties:
secrets:
type: array
token_file_path:
type: string
secret_path:
type: string
secret_key:
Expand Down

0 comments on commit e4de2ce

Please sign in to comment.