Skip to content

Commit

Permalink
feat: add some helper scripts for OpenStack Helm
Browse files Browse the repository at this point in the history
These scripts help deal with OpenStack Helm and it's quirky usage of
helm charts and secrets, which can't really be externalized.
  • Loading branch information
cardoe committed Feb 2, 2024
1 parent c5b3e7f commit 7ba40ae
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
3 changes: 3 additions & 0 deletions scripts/openstack-helm-depend-sync.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

cd $(git rev-parse --show-toplevel)/openstack-helm && helm dep up "$1"
39 changes: 39 additions & 0 deletions scripts/openstack-helm-sealed-secrets.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/bash

# function to process each YAML file
process_yaml() {
kind=$(echo "$1" | yq e '.kind')
if [[ "${kind}" == "Secret" ]]; then
# its a match, encrypt it
echo "$1" | \
kubeseal \
--scope cluster-wide \
--allow-empty-data \
-o yaml
else
# not a match just output it
echo "---"
echo "$1"
fi
}

NL=$'\n'

# read the stream from stdin and break up each YAML doc
yaml_acc=""
while IFS= read -r line; do
if [[ $line =~ ^---$ ]]; then
# process each YAML file
if [[ -n $yaml_acc ]]; then
process_yaml "$yaml_acc"
yaml_acc=""
fi
else
# accumulate the lines of the current YAML doc
yaml_acc+="${line}${NL}"

fi
done

# process the last one
[[ -n $yaml_acc ]] && process_yaml "$yaml_acc"

0 comments on commit 7ba40ae

Please sign in to comment.