Skip to content

Conversation

heurtematte
Copy link
Contributor

Allow use of Vault CLI as a replacement for Pass.

sm_read <mount> <path>
sm_write <mount> <path> key1=value1 key2=value2 ...

Including test file: secretsmanager_wrapper_test.sh

Patch example for add_creds.sh

diff --git a/pass/add_creds.sh b/pass/add_creds.sh
index 7bbc16e..3c91eed 100755
--- a/pass/add_creds.sh
+++ b/pass/add_creds.sh
@@ -17,6 +17,7 @@ IFS=$'\n\t'
 SCRIPT_FOLDER="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"
 
 source "${SCRIPT_FOLDER}/pass_wrapper.sh"
+source "${SCRIPT_FOLDER}/secretsmanager_wrapper.sh"
 
 _verify_inputs() {
   local project_name="${1:-}"
@@ -40,7 +41,7 @@ _check_pw_does_not_exist() {
   local pw_store_path="bots/${project_name}/${path}"
 
   # check that the entries do not exist yet
-  if passw cbi "${pw_store_path}" &> /dev/null ; then
+  if sm_read "cbi" "$pw_store_path" &> /dev/null ; then
     printf "%s credentials for %s already exist. Skipping creation...\n" "${path}" "${project_name}"
     return 1
   fi
@@ -66,12 +67,8 @@ _add_to_pw_store() {
   local email="${3:-}"
   local user="${4:-}"
   local pw="${5:-}"
-
-  local pw_store_path="bots/${project_name}/${site}"
-
-  echo "${email}" | passw cbi insert --echo "${pw_store_path}/email"
-  echo "${user}" | passw cbi insert --echo "${pw_store_path}/username"
-  echo "${pw}" | passw cbi insert --echo "${pw_store_path}/password"
+  local pw_store_path="${project_name}/${site}"
+  echo "${pw}" | sm_write "cbi" "$pw_store_path" "email=${email}" "username=${user}" "password=-"
 }
 
 _generate_ssh_keys() {
``

@eclipsewebmaster eclipsewebmaster force-pushed the feat/secretsmanager_wrapper branch from 7b8de21 to f262d10 Compare August 2, 2024 15:10
@heurtematte heurtematte requested a review from fredg02 August 2, 2024 15:17
Signed-off-by: sebastien.heurtematte <[email protected]>
@eclipsewebmaster eclipsewebmaster force-pushed the feat/secretsmanager_wrapper branch from f262d10 to d3e4973 Compare August 2, 2024 15:24
Copy link

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.

1 participant