Skip to content

Commit

Permalink
Fix some stylings
Browse files Browse the repository at this point in the history
  • Loading branch information
florianrusch committed Nov 24, 2023
1 parent 3ab185e commit 9badff2
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 28 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@ trim_trailing_whitespace = true

[{*.go,Makefile,go.mod,go.sum}]
indent_style = tab

[*.sh]
indent_size = 4
9 changes: 4 additions & 5 deletions samples/HashiCorp-Vault/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Sample: Backup HashiCorp Vault

In this example we will show you how to backup an HashiCorp Vault instance.
In this example we will show you how to back up an HashiCorp Vault instance.

## Requirements

Expand Down Expand Up @@ -47,9 +47,9 @@ something around 1 minute until the init script finishes.

```shell
$ docker-compose ps --all
NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS
hashicorp-vault-vault-1 hashicorp/vault:1.15 "vault server -confi…" vault 59 seconds ago Up 58 seconds 0.0.0.0:8200->8200/tcp
hashicorp-vault-vault-init-1 hashicorp-vault-vault-init "bash /init.sh" vault-init 59 seconds ago Exited (0) 5 seconds ago
NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS
hashicorp-vault-vault-1 hashicorp/vault:1.15 "vault server -confi…" vault 59 seconds ago Up 58 seconds 0.0.0.0:8200->8200/tcp
hashicorp-vault-vault-init-1 hashicorp-vault-vault-init "bash /init.sh" vault-init 59 seconds ago Exited (0) 5 seconds ago
```

### 3. Run lifeboat to create the backup
Expand All @@ -75,7 +75,6 @@ To clean up everything afterwards, we just need to execute the following command
$ rm -rf backup-destination/vault-backup.snap
```


## Restore

An official guide how to restore a backup/snapshot can be found here:
Expand Down
26 changes: 13 additions & 13 deletions samples/HashiCorp-Vault/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ services:
- IPC_LOCK
entrypoint: vault server -config=/vault/vault.hcl

# vault-init:
# build:
# context: .
# dockerfile_inline: |
# FROM hashicorp/vault:1.15
# RUN apk update && \
# apk add bash
# no_cache: true
# volumes:
# - ./init-and-fill-vault-with-data.sh:/init.sh:ro
# - ./vault-token.txt:/vault-token.txt:rw
# - ./vault-unseal-keys.txt:/vault-unseal-keys.txt:rw
# entrypoint: bash /init.sh
vault-init:
build:
context: .
dockerfile_inline: |
FROM hashicorp/vault:1.15
RUN apk update && \
apk add bash
no_cache: true
volumes:
- ./init-and-fill-vault-with-data.sh:/init.sh:ro
- ./vault-token.txt:/vault-token.txt:rw
- ./vault-unseal-keys.txt:/vault-unseal-keys.txt:rw
entrypoint: bash /init.sh
20 changes: 10 additions & 10 deletions samples/HashiCorp-Vault/init-and-fill-vault-with-data.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ until $(vault status > /dev/null 2>&1); do
fi

if [ ${attempt_counter} -eq ${max_attempts} ]; then
echo ""
echo "ERROR: The Vault was not started in time. Maximum connection attempts of ${max_attempts} have been reached and $((sleep_seconds*max_attempts)) seconds have been waited. Please have a look at the Vault instance to see why it did not start in time."
exit 1
echo ""
echo "ERROR: The Vault was not started in time. Maximum connection attempts of ${max_attempts} have been reached and $((sleep_seconds*max_attempts)) seconds have been waited. Please have a look at the Vault instance to see why it did not start in time."
exit 1
fi

echo "Waiting until vault is up..."
Expand Down Expand Up @@ -71,10 +71,10 @@ unsealKeys=$(echo "$initOutput" | grep "^Unseal Key ")
# Get root token
while IFS= read -r SINGLELINE
do
re="Initial Root Token: "
if [[ "${SINGLELINE}" =~ $re ]]; then
rootToken=$(echo "${SINGLELINE}" | sed "s/${re}//")
fi
re="Initial Root Token: "
if [[ "${SINGLELINE}" =~ $re ]]; then
rootToken=$(echo "${SINGLELINE}" | sed "s/${re}//")
fi
done << EOF
$initOutput
EOF
Expand All @@ -101,9 +101,9 @@ vault secrets enable -version=2 -path="secret" kv
amountOfSecrets=1000
secretLength=2000
for i in `seq 2 $amountOfSecrets`; do
printf "\nPut secret number ${i} into vault:\n"
superSecureSecret=$(sed "s/[^a-zA-Z0-9]//g" <<< $(cat /dev/urandom | LC_ALL=C tr -dc 'a-zA-Z0-9!@#$%*()-+' | fold -w ${secretLength} | head -n 1))
echo "${superSecureSecret}" | vault kv put secret/${i} content=-
printf "\nPut secret number ${i} into vault:\n"
superSecureSecret=$(sed "s/[^a-zA-Z0-9]//g" <<< $(cat /dev/urandom | LC_ALL=C tr -dc 'a-zA-Z0-9!@#$%*()-+' | fold -w ${secretLength} | head -n 1))
echo "${superSecureSecret}" | vault kv put secret/${i} content=-
done

printf "\nSuccessful initialized vault and put ${amountOfSecrets} with a length of ${secretLength} random chars into vault\n"

0 comments on commit 9badff2

Please sign in to comment.