-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(feat) Add script to build and diff components
- Loading branch information
1 parent
9715d8e
commit e4961fa
Showing
3 changed files
with
52 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 |
---|---|---|
|
@@ -11,3 +11,4 @@ TALOS_CONFIG | |
*.key | ||
.tool-versions | ||
charts/ | ||
/tmp |
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
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,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 |