Skip to content

Commit

Permalink
(feat) Add script to build and diff components
Browse files Browse the repository at this point in the history
  • Loading branch information
aisling136 committed Apr 24, 2024
1 parent 9715d8e commit e4961fa
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ TALOS_CONFIG
*.key
.tool-versions
charts/
/tmp
1 change: 1 addition & 0 deletions scripts/cleanup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
find -type d -name generated_configs | xargs rm -rf
find -type d -name charts | xargs rm -rf
find . -name '*.terraform*' | xargs rm -rf
find . -name tmp | xargs rm -rf
50 changes: 50 additions & 0 deletions scripts/component.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/bin/bash

diff=false
namespace=''
component=''
while getopts "c:d:" arg; do
case $arg in
c) component=$OPTARG
;;
d) diff=true
namespace=$OPTARG
;;
esac
done

dir=$(find -maxdepth 3 -type d -name $component)
echo $dir
if [ -z $dir ]; then
echo "Could not find app directory. Find had no result."
exit 1
fi

IFS='/' read -a dir_array <<< $dir

if [ ${#dir_array[@]} -ne 4 ]; then
echo "Could not find app directory. Find returned $dir."
exit 1
fi

echo "Found application ${dir_array[3]}. Running kustomize build"

kustomize build $dir \
--load-restrictor=LoadRestrictionsNone \
--enable-helm \
--enable-alpha-plugins \
--enable-exec \
> ./tmp/${dir_array[3]}_kustomize.yaml

echo "Wrote kustomize output to ./tmp/${dir_array[3]}_kustomize.yaml"

if $diff; then
echo "Running diff against namespace $namespace"

kubectl diff \
-f ./tmp/${dir_array[3]}_kustomize.yaml \
-n $namespace \
> ./tmp/${dir_array[3]}_diff.yaml

echo "diff output written to ./tmp/${dir_array[3]}_diff.yaml"
fi

0 comments on commit e4961fa

Please sign in to comment.