Skip to content

Instantly share code, notes, and snippets.

@jrepp
Created April 28, 2020 23:48
Show Gist options
  • Save jrepp/c413618d5b886fdc8caffb20a4dccf15 to your computer and use it in GitHub Desktop.
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
#!/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