From 44b08280931fc0da0a306820179bbf3406568969 Mon Sep 17 00:00:00 2001 From: Richard Simpson Date: Mon, 3 Feb 2020 21:28:43 -0600 Subject: [PATCH] docs: some small formatting and doc changes --- README.md | 15 ++++++++------- action.js | 18 +++++++++--------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index cffd45d..a0ff1cc 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ # vault-action -A helper action for easily pulling secrets from a K/V backend of vault. +A helper action for easily pulling secrets from the K/V backend of vault. + +Expects [Version 2](https://www.vaultproject.io/docs/secrets/kv/kv-v2/) of the KV Secrets Engine by default. ## Example Usage @@ -39,7 +41,7 @@ with: url: https://vault.mycompany.com:8200 method: approle roleId: ${{ secrets.roleId }} - secretId : ${{ secrets.secretId }} + secretId: ${{ secrets.secretId }} ``` ## Key Syntax @@ -97,22 +99,21 @@ with: By default, `vault-action` expects a K/V engine using [version 2](https://www.vaultproject.io/docs/secrets/kv/kv-v2.html). -In order to work with a v1 engine, the `kv-version` parameter may be passed: +In order to work with a [v1 engine](https://www.vaultproject.io/docs/secrets/kv/kv-v1/), the `kv-version` parameter may be passed: ```yaml with: kv-version: 1 ``` -### Custom Engine Name +### Custom Engine Path -Vault comes with a default engine named `secret`, so a secret named `ci` will be -accessed from `secret/ci`. However, if you are using a custom named engine, you +When you enable the K/V Engine, by default it's placed at the path `secret`, so a secret named `ci` will be accessed from `secret/ci`. However, [if you enabled the secrets engine using a custom `path`](https://www.vaultproject.io/docs/commands/secrets/enable/#inlinecode--path-4), you can pass it as follows: ```yaml with: - engine-name: my-secrets + path: my-secrets secrets: ci npmToken ``` diff --git a/action.js b/action.js index 968e0de..fa8f157 100644 --- a/action.js +++ b/action.js @@ -7,7 +7,7 @@ async function exportSecrets() { const vaultUrl = core.getInput('url', { required: true }); const vaultNamespace = core.getInput('namespace', { required: false }); - let engineName = core.getInput('engine-name', { required: false }); + let enginePath = core.getInput('path', { required: false }); let kvVersion = core.getInput('kv-version', { required: false }); const secretsInput = core.getInput('secrets', { required: true }); @@ -47,16 +47,16 @@ async function exportSecrets() { break; } - if (!engineName){ - engineName = 'secret'; + if (!enginePath) { + enginePath = 'secret'; } - if (!kvVersion){ + if (!kvVersion) { kvVersion = '2'; } if (kvVersion !== '1' && kvVersion !== '2') { - throw Error(`You must provide a valid K/V version. Input: "${kvVersion}"`); + throw Error(`You must provide a valid K/V version (1 or 2). Input: "${kvVersion}"`); } kvVersion = parseInt(kvVersion); @@ -148,14 +148,14 @@ function parseResponse(responseBody, kvVersion) { let secretData; switch(kvVersion) { - case 1: + case 1: { secretData = parsedResponse.data; - break; + } break; - case 2: + case 2: { const vaultKeyData = parsedResponse.data; secretData = vaultKeyData.data; - break; + } break; } return secretData;