Last active
October 2, 2019 11:09
-
-
Save niqdev/fffc1b27f50cbc6436e264b8d48a1b62 to your computer and use it in GitHub Desktop.
Generate ArgoCD helm chart
This file contains hidden or 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
#!/bin/bash | |
PREFIX="argo-cd-" | |
INSTALL_FILE="install.yaml" | |
TEMPLATES_PATH="templates/" | |
# reset templates | |
rm -fr ${TEMPLATES_PATH} | |
mkdir -p ${TEMPLATES_PATH} | |
cd ${TEMPLATES_PATH} | |
# https://argoproj.github.io/argo-cd/getting_started/#1-install-argo-cd | |
curl -s -o ${INSTALL_FILE} https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml | |
# split by resource type | |
split -p "---" -a 3 ${INSTALL_FILE} ${PREFIX} | |
function extract_file_name { | |
local FILE=$1 | |
# extract second column from lines starting with "kind" | |
# prefix upper case with dash | |
# convert upper to lower case | |
# add file extension | |
awk '/^kind/ { print $2 }' $FILE | | |
sed 's/\(.\)\([A-Z]\)/\1-\2/g' | | |
tr '[:upper:]' '[:lower:]' | | |
awk '{ print $1".yaml" }' | |
} | |
# append content to file of the same resource type | |
for FILE in ${PREFIX}*; do | |
FILE_NAME=$(extract_file_name $FILE) | |
cat $FILE >> $FILE_NAME | |
done | |
# remove comment | |
find . -type f -name '*.yaml' -exec sed -i '.orig' 's/^.*DO NOT EDIT$/---/' {} \; | |
# cleanup | |
rm ${INSTALL_FILE} | |
rm ${PREFIX}* | |
rm *".orig" |
Author
niqdev
commented
May 18, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment