Created
April 28, 2020 23:48
-
-
Save jrepp/c413618d5b886fdc8caffb20a4dccf15 to your computer and use it in GitHub Desktop.
This script will take a helm deployment and split into multiple files, helpful if you just want to diff a single part of the deployment
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
#!/usr/bin/env bash | |
for f in $(ls -1 *deploy.yaml); do | |
echo processing $f | |
abspath=$(realpath ${f}) | |
# build the output sub-directory | |
base_name=$(basename ${f}) | |
name_only=${base_name%.*} | |
mkdir -p $name_only | |
pushd $name_only | |
awk ' | |
/# Source: /{ | |
close(file) | |
file=$NF | |
print " creating file " file | |
system("mkdir -p $(dirname "file")") | |
} | |
file!="" && !/^--/{ | |
print > (file) | |
} | |
' $abspath | |
popd | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment