From ee19e2b84718ed35050d9a6f95cbc70c9786c23a Mon Sep 17 00:00:00 2001 From: Rustam Tagaev Date: Mon, 1 Jun 2020 20:03:41 +0300 Subject: [PATCH] #new-plugin add a new plugin "vault-switch" --- plugins/vault-switch/README.md | 29 ++++++++++ plugins/vault-switch/example.png | Bin 0 -> 4246 bytes plugins/vault-switch/vault-switch.plugin.zsh | 57 +++++++++++++++++++ 3 files changed, 86 insertions(+) create mode 100644 plugins/vault-switch/README.md create mode 100644 plugins/vault-switch/example.png create mode 100644 plugins/vault-switch/vault-switch.plugin.zsh diff --git a/plugins/vault-switch/README.md b/plugins/vault-switch/README.md new file mode 100644 index 000000000..7dd07f82d --- /dev/null +++ b/plugins/vault-switch/README.md @@ -0,0 +1,29 @@ +# Vault-switch plugin + +## Description + +This plugin can switch among nodes of Vault - HashiCorp + +## Configuration + +For using a plugin you should add VAULT_NODES to **~/.zshrc** +Variable **VAULT_NODES** must look as + +```bash +VAULT_NODES="node1,https://vault1.example.com,secret_token1;node2,https://vault2.example.com,secret_token2" +``` + +If you want to skip verify checking of ssl then add true to end of the string. + +```bash +VAULT_NODES="node1,https://vault1.example.com,secret_token1,true;node2,https://vault2.example.com,secret_token2" +``` + +Name of a node, address, token are separating comma. Other nodes separate semicolon. +After need to add the name of the plugin to **~/.zshrc** to variable **plugins=(vault-switch)** + +**Example usage:** + +![vault-switch](example.png) + +State of restoring stored in **~/.vault-switch/credentials** diff --git a/plugins/vault-switch/example.png b/plugins/vault-switch/example.png new file mode 100644 index 0000000000000000000000000000000000000000..055b8e534ca2f8fd36ec38bbd9b6cde4090053dd GIT binary patch literal 4246 zcmV;H5NYp;P)erc$8dk)+WxpTH&Es zH#-2h8KZCnvwxf<*XyXpTPe+JWVlSg4|}Wk;gio*OigvcL*aU}=0R}h5KsGValKw& zuh(WA>;c`AU$TL_I06nudxL$BfCqW4bx0)>x8n1Agi?rrF)6LyFCPsdYPsR@ixKDT zs$QyzR4gZJRTji0bG>5rKmQe;|5|vxk3c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mx28J z*X^x0akKEyt)5+#e>~wJ$!~~P`OKSn8E)5?MOki8LRmuLzrXw4llbXmGNpSODMAF*ryu{m(xDa?$&-wQv4ZuRu~@oQO=_35|= zKYl$b(M00Mr+(EQLNhgE&ceN z4jSKaBy$DaIh+mS{P-OJ2RsbEfABH?v!OfDC!c;+F7ZP=POq*#%24p*=TCArEIi+A z0YE?c#7c#Kyaxb4wEXy$OZ?8yl8-ljKYrk2@~l(q)nsj8nHw@5s(Tw}iGfvlVu;gW zuhq`VdZjUmbLw|Cgqv-F)iWpHK_Iz87Owty4*>enC-}#Ep8k{Rj6dEhC4NkM?@$Oa zd1(v5rdYvlD@DoudbMujtb4y6IHYQ9^Hr-}Z>(S0D{`4P+@6nsh=?B)*3guKxS)c-mv;qSuOIEkB4J0ZjOhH|vi#h5jwk=yLse zNz;fJ&L86B4G?3b-54FV(?#*aFPioMspn=d>biDk+C#<$3__E;4bPY8>K2a}=G+Fm zyKN+A{uO@woRL9Pc9>sF)6>x2n*IKkgn2$slx{odQ0AWdK^;GS*(U(qYynaa&3>E> z!SU+umH3^XC2b^rZd5!%+v&Q@Hk7_Ard{_-p}bxh`(Y ${FILE_CREDENTIALS} + echo "export VAULT_SELECT_NODE=${VAULT_SELECT_NODE}" >> ${FILE_CREDENTIALS} + echo "export VAULT_ADDR=${VAULT_ADDR}" >> ${FILE_CREDENTIALS} + echo "export VAULT_TOKEN=${VAULT_TOKEN}" >> ${FILE_CREDENTIALS} + [[ $VAULT_SKIP_VERIFY ]] && echo "export VAULT_SKIP_VERIFY=true" >> ${FILE_CREDENTIALS} + + _list-nodes + fi + +} + +function vault-switch() { + _get-nodes + [ ! $1 ] && _list-nodes + [ $1 ] && _set-work-node $1 +}