2022-11-16 14:23:58 -05:00
|
|
|
#!/usr/bin/env bash
|
2023-03-15 12:00:52 -04:00
|
|
|
# Copyright (c) HashiCorp, Inc.
|
2023-08-10 21:14:03 -04:00
|
|
|
# SPDX-License-Identifier: BUSL-1.1
|
2023-03-15 12:00:52 -04:00
|
|
|
|
2022-11-16 14:23:58 -05:00
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
|
|
function retry {
|
|
|
|
|
local retries=$1
|
|
|
|
|
shift
|
|
|
|
|
local count=0
|
|
|
|
|
|
|
|
|
|
until "$@"; do
|
|
|
|
|
exit=$?
|
|
|
|
|
wait=$((2 ** count))
|
|
|
|
|
count=$((count + 1))
|
|
|
|
|
if [ "$count" -lt "$retries" ]; then
|
|
|
|
|
sleep "$wait"
|
|
|
|
|
else
|
|
|
|
|
return "$exit"
|
|
|
|
|
fi
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function fail {
|
|
|
|
|
echo "$1" 1>&2
|
|
|
|
|
exit 1
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-13 11:43:26 -05:00
|
|
|
binpath=${VAULT_INSTALL_DIR}/vault
|
|
|
|
|
testkey=${TEST_KEY}
|
|
|
|
|
testvalue=${TEST_VALUE}
|
2022-11-16 14:23:58 -05:00
|
|
|
|
|
|
|
|
test -x "$binpath" || fail "unable to locate vault binary at $binpath"
|
|
|
|
|
|
|
|
|
|
retry 5 $binpath kv put secret/test $testkey=$testvalue
|