-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add some helper scripts for OpenStack Helm
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
Showing
2 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |