Skip to content

Commit

Permalink
some vault helper updates
Browse files Browse the repository at this point in the history
  • Loading branch information
fairclothjm committed Dec 1, 2021
1 parent 63705bf commit cdb86de
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 9 deletions.
1 change: 1 addition & 0 deletions bash/.bash_functions
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ got() {
go test -v "$@" > $logfile
fi

echo "$(date)"
grep -v " --- PASS:" $logfile | grep "PASS:"
GREP_COLOR='0;31' grep "FAIL:" $logfile
tail -n 1 $logfile
Expand Down
53 changes: 44 additions & 9 deletions bash/.vaultrc
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@ alias vaudit="vault audit enable file file_path=/tmp/vault_audit.log"
alias vdebug='GCFLAGS="all=-N -l" make dev'
alias vdlv="dlv --listen=:2345 --headless=true --api-version=2 exec ./pkg/darwin_amd64/vault -- server -dev -log-level=debug -dev-root-token-id=root"
alias vedit="vim /Users/$USER/code/dotfiles/bash/.vaultrc"
alias vserve="vault server -dev -dev-root-token-id=root -log-level=trace -dev-plugin-dir=/Users/$USER/dev/plugins"
alias vservecluster="vault server -dev -dev-root-token-id=root -log-level=debug -dev-three-node"

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# Functions

# run vault in dev mode
# run dev build of vault in dev mode
# optionally pass in "&" to run in the background
vdev() {
./pkg/darwin_amd64/vault server \
Expand All @@ -29,18 +28,31 @@ vdev() {
"$@"
}

# run vault in dev mode
# optionally pass in "&" to run in the background
vserve() {
vault server \
-dev \
-dev-root-token-id=root \
-log-level=trace \
-dev-plugin-dir=/Users/$USER/dev/plugins \
"$@"
}

vset() {
export VAULT_DEV_ROOT_TOKEN_ID="root"
export VAULT_TOKEN="root"
export VAULT_ADDR="http://127.0.0.1:8200"
export VAULT_LICENSE_PATH="/Users/$USER/dev/license/vault.hclic"
export VAULT_LICENSE="$(cat /Users/$USER/dev/license/vault.hclic)"
}

vunset() {
unset VAULT_DEV_ROOT_TOKEN_ID
unset VAULT_TOKEN
unset VAULT_ADDR
unset VAULT_CACERT
unset VAULT_LICENSE
unset VAULT_LICENSE_PATH
unset VAULT_NAMESPACE
}
Expand All @@ -51,6 +63,7 @@ vv() {
echo "VAULT_TOKEN=$VAULT_TOKEN"
echo "VAULT_ADDR=$VAULT_ADDR"
echo "VAULT_CACERT=$VAULT_CACERT"
echo "VAULT_LICENSE=$VAULT_LICENSE"
echo "VAULT_LICENSE_PATH=$VAULT_LICENSE_PATH"
echo "VAULT_NAMESPACE=$VAULT_NAMESPACE"

Expand All @@ -62,11 +75,33 @@ vv() {
fi
}

# kill vault proccess
vkill() {
ps aux | \
pgrep "vault server" | \
awk '{print $2}' | \
xargs kill -9
}
# vault backport
# usage: vbp 1.9 12345 dfhafefdfda
vbp() {
local version="$1"
local issue="$2"
local sha="$3"

[[ ${version:?} ]]
[[ ${issue:?} ]]
[[ ${sha:?} ]]

local bp_branch=backport-pr-${issue}-${version}.x
local rel_branch=release/${version}.x

git checkout ${rel_branch}
git pull
git checkout -b ${bp_branch}
git cherry-pick ${sha}

echo
echo "Backports https://github.com/hashicorp/vault/pull/${issue} into ${rel_branch}"
echo
echo "Steps:"
echo '```'
echo "git checkout ${rel_branch}"
echo "git checkout -b ${bp_branch}"
echo "git cherry-pick ${sha}"
echo '```'
echo
}

0 comments on commit cdb86de

Please sign in to comment.