mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-02-11 05:39:45 +08:00
Compare commits
5 Commits
7580b56add
...
490d34581f
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
490d34581f | ||
|
|
41c5b9677a | ||
|
|
116be8badd | ||
|
|
43079320a2 | ||
|
|
ee19e2b847 |
2
.github/workflows/dependencies.yml
vendored
2
.github/workflows/dependencies.yml
vendored
@ -13,7 +13,7 @@ jobs:
|
|||||||
contents: write # this is needed to push commits and branches
|
contents: write # this is needed to push commits and branches
|
||||||
steps:
|
steps:
|
||||||
- name: Harden the runner (Audit all outbound calls)
|
- name: Harden the runner (Audit all outbound calls)
|
||||||
uses: step-security/harden-runner@e3f713f2d8f53843e71c69a996d56f51aa9adfb9 # v2.14.1
|
uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2
|
||||||
with:
|
with:
|
||||||
egress-policy: audit
|
egress-policy: audit
|
||||||
|
|
||||||
|
|||||||
4
.github/workflows/installer.yml
vendored
4
.github/workflows/installer.yml
vendored
@ -26,7 +26,7 @@ jobs:
|
|||||||
- macos-latest
|
- macos-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Harden the runner (Audit all outbound calls)
|
- name: Harden the runner (Audit all outbound calls)
|
||||||
uses: step-security/harden-runner@e3f713f2d8f53843e71c69a996d56f51aa9adfb9 # v2.14.1
|
uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2
|
||||||
with:
|
with:
|
||||||
egress-policy: audit
|
egress-policy: audit
|
||||||
|
|
||||||
@ -47,7 +47,7 @@ jobs:
|
|||||||
- test
|
- test
|
||||||
steps:
|
steps:
|
||||||
- name: Harden the runner (Audit all outbound calls)
|
- name: Harden the runner (Audit all outbound calls)
|
||||||
uses: step-security/harden-runner@e3f713f2d8f53843e71c69a996d56f51aa9adfb9 # v2.14.1
|
uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2
|
||||||
with:
|
with:
|
||||||
egress-policy: audit
|
egress-policy: audit
|
||||||
|
|
||||||
|
|||||||
2
.github/workflows/main.yml
vendored
2
.github/workflows/main.yml
vendored
@ -24,7 +24,7 @@ jobs:
|
|||||||
if: github.repository == 'ohmyzsh/ohmyzsh'
|
if: github.repository == 'ohmyzsh/ohmyzsh'
|
||||||
steps:
|
steps:
|
||||||
- name: Harden the runner (Audit all outbound calls)
|
- name: Harden the runner (Audit all outbound calls)
|
||||||
uses: step-security/harden-runner@e3f713f2d8f53843e71c69a996d56f51aa9adfb9 # v2.14.1
|
uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2
|
||||||
with:
|
with:
|
||||||
egress-policy: audit
|
egress-policy: audit
|
||||||
|
|
||||||
|
|||||||
2
.github/workflows/project.yml
vendored
2
.github/workflows/project.yml
vendored
@ -17,7 +17,7 @@ jobs:
|
|||||||
if: github.repository == 'ohmyzsh/ohmyzsh'
|
if: github.repository == 'ohmyzsh/ohmyzsh'
|
||||||
steps:
|
steps:
|
||||||
- name: Harden the runner (Audit all outbound calls)
|
- name: Harden the runner (Audit all outbound calls)
|
||||||
uses: step-security/harden-runner@e3f713f2d8f53843e71c69a996d56f51aa9adfb9 # v2.14.1
|
uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2
|
||||||
with:
|
with:
|
||||||
egress-policy: audit
|
egress-policy: audit
|
||||||
- name: Authenticate as @ohmyzsh
|
- name: Authenticate as @ohmyzsh
|
||||||
|
|||||||
4
.github/workflows/scorecard.yml
vendored
4
.github/workflows/scorecard.yml
vendored
@ -36,7 +36,7 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Harden the runner (Audit all outbound calls)
|
- name: Harden the runner (Audit all outbound calls)
|
||||||
uses: step-security/harden-runner@e3f713f2d8f53843e71c69a996d56f51aa9adfb9 # v2.14.1
|
uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2
|
||||||
with:
|
with:
|
||||||
egress-policy: audit
|
egress-policy: audit
|
||||||
|
|
||||||
@ -60,6 +60,6 @@ jobs:
|
|||||||
retention-days: 5
|
retention-days: 5
|
||||||
|
|
||||||
- name: "Upload to code-scanning"
|
- name: "Upload to code-scanning"
|
||||||
uses: github/codeql-action/upload-sarif@b20883b0cd1f46c72ae0ba6d1090936928f9fa30 # v4.32.0
|
uses: github/codeql-action/upload-sarif@45cbd0c69e560cd9e7cd7f8c32362050c9b7ded2 # v4.32.2
|
||||||
with:
|
with:
|
||||||
sarif_file: results.sarif
|
sarif_file: results.sarif
|
||||||
|
|||||||
29
plugins/vault-switch/README.md
Normal file
29
plugins/vault-switch/README.md
Normal file
@ -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:**
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
State of restoring stored in **~/.vault-switch/credentials**
|
||||||
BIN
plugins/vault-switch/example.png
Normal file
BIN
plugins/vault-switch/example.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.1 KiB |
57
plugins/vault-switch/vault-switch.plugin.zsh
Normal file
57
plugins/vault-switch/vault-switch.plugin.zsh
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
autoload -U add-zsh-hook
|
||||||
|
add-zsh-hook precmd _restore_cache
|
||||||
|
|
||||||
|
FILE_CREDENTIALS="${HOME}/.vault-switch/credentials"
|
||||||
|
|
||||||
|
_restore_cache(){
|
||||||
|
[ ! -d ${HOME}/.vault-switch ] && mkdir -p ${HOME}/.vault-switch
|
||||||
|
[ ! -f $FILE_CREDENTIALS ] && touch ${FILE_CREDENTIALS}
|
||||||
|
source ${FILE_CREDENTIALS}
|
||||||
|
}
|
||||||
|
|
||||||
|
_get-nodes(){
|
||||||
|
IFS=";" read -A NODES <<< ${VAULT_NODES}
|
||||||
|
}
|
||||||
|
|
||||||
|
_set-color(){
|
||||||
|
echo "\e[1;32m$1\e[0m"
|
||||||
|
}
|
||||||
|
|
||||||
|
_list-nodes(){
|
||||||
|
INDEX=1
|
||||||
|
for i in ${NODES[@]}
|
||||||
|
do
|
||||||
|
NODE=$(echo $i | cut -d "," -f 1)
|
||||||
|
[[ "${NODE}" == "${VAULT_SELECT_NODE}" ]] && ASTERISK="*"
|
||||||
|
echo "${INDEX}) ${NODE} $(_set-color ${ASTERISK})"
|
||||||
|
INDEX=$[$INDEX+1]
|
||||||
|
unset ASTERISK
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
_set-work-node(){
|
||||||
|
if [ $1 -gt ${#NODES[@]} ]
|
||||||
|
then
|
||||||
|
echo "Number of node not found"
|
||||||
|
else
|
||||||
|
VAULT_SELECT_NODE=$(echo ${NODES[$1]} | cut -d "," -f 1)
|
||||||
|
VAULT_ADDR=$(echo ${NODES[$1]} | cut -d "," -f 2)
|
||||||
|
VAULT_TOKEN=$(echo ${NODES[$1]} | cut -d "," -f 3)
|
||||||
|
VAULT_SKIP_VERIFY=$(echo ${NODES[$1]} | cut -d "," -f 4)
|
||||||
|
|
||||||
|
echo > ${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
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
vault-switch() {
|
||||||
|
_get-nodes
|
||||||
|
[ ! $1 ] && _list-nodes
|
||||||
|
[ $1 ] && _set-work-node $1
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user