added semver maker and two chaos experiments
Signed-off-by: rajdas <mail.rajdas@gmail.com>
This commit is contained in:
24
scripts/push.sh
Normal file
24
scripts/push.sh
Normal file
@@ -0,0 +1,24 @@
|
||||
#!/bin/sh
|
||||
|
||||
setup_git() {
|
||||
git config --global user.email "travis@travis-ci.org"
|
||||
git config --global user.name "Travis CI"
|
||||
git remote set-url origin https://${GITHUB_TOKEN}@github.com/rajdas98/community-charts.git > /dev/null 2>&1
|
||||
}
|
||||
|
||||
commit_website_files() {
|
||||
git checkout master
|
||||
git status
|
||||
git add .
|
||||
git commit --message "Travis build: $TRAVIS_BUILD_NUMBER"
|
||||
git status
|
||||
}
|
||||
|
||||
upload_files() {
|
||||
git remote -v
|
||||
git push origin master
|
||||
}
|
||||
|
||||
setup_git
|
||||
commit_website_files
|
||||
upload_files
|
11
scripts/semversion_checker.py
Normal file
11
scripts/semversion_checker.py
Normal file
@@ -0,0 +1,11 @@
|
||||
import re
|
||||
import sys
|
||||
|
||||
# semantic version regex
|
||||
regex = "^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$"
|
||||
result = re.search(regex, sys.argv[1])
|
||||
|
||||
if result:
|
||||
sys.exit(0) # on success
|
||||
else:
|
||||
sys.exit(1) #on failure
|
75
scripts/version_maker.sh
Normal file
75
scripts/version_maker.sh
Normal file
@@ -0,0 +1,75 @@
|
||||
#! /bin/bash
|
||||
|
||||
# parsing yaml file
|
||||
function yaml() {
|
||||
local prefix=$2
|
||||
local s='[[:space:]]*' w='[a-zA-Z0-9_]*' fs=$(echo @|tr @ '\034')
|
||||
sed -ne "s|^\($s\):|\1|" \
|
||||
-e "s|^\($s\)\($w\)$s:$s[\"']\(.*\)[\"']$s\$|\1$fs\2$fs\3|p" \
|
||||
-e "s|^\($s\)\($w\)$s:$s\(.*\)$s\$|\1$fs\2$fs\3|p" $1 |
|
||||
awk -F$fs '{
|
||||
indent = length($1)/2;
|
||||
vname[indent] = $2;
|
||||
for (i in vname) {if (i > indent) {delete vname[i]}}
|
||||
if (length($3) > 0) {
|
||||
vn=""; for (i=0; i<indent; i++) {vn=(vn)(vname[i])("_")}
|
||||
printf("%s%s%s=\"%s\"\n", "'$prefix'",vn, $2, $3);
|
||||
}
|
||||
}'
|
||||
}
|
||||
|
||||
# find files ended with chartserviceversion.yaml
|
||||
FIND_CMD=`find ./charts -type f -name "*basetemplate.yaml"`
|
||||
|
||||
# add all the files to an array called files
|
||||
files=$(echo $FIND_CMD | tr " " "\n")
|
||||
|
||||
# looping from all the files
|
||||
for file in $files
|
||||
do
|
||||
# get the latest version from the template file
|
||||
|
||||
eval $(yaml $file)
|
||||
kind=$kind
|
||||
|
||||
if [ $kind == "ChaosExperiment" ]; then
|
||||
newversion=$metadata_version
|
||||
elif [ $kind == "ChartServiceVersion" ]; then
|
||||
newversion=$spec_version
|
||||
fi
|
||||
|
||||
# if version is interger or float (semversion)
|
||||
result=sudo python scripts/semversion_checker.py $newversion
|
||||
if [ $? == 0 ]; then
|
||||
temp=$(echo ${file::-18})
|
||||
|
||||
if [ $kind == "ChartServiceVersion" ]; then
|
||||
# echo $temp
|
||||
oldversionfile=$temp'.yaml'
|
||||
echo $oldversionfile
|
||||
eval $(yaml $oldversionfile)
|
||||
|
||||
oldversion=$spec_version
|
||||
echo $oldversion
|
||||
|
||||
`sed -i "s/[[:alnum:]]*$oldversion/$newversion/" $oldversionfile`
|
||||
`sed -i -e "s/version:[[:space:]]*$oldversion/version: {{ VERSION }}/" $file`
|
||||
|
||||
elif [ $kind == "ChaosExperiment" ]; then
|
||||
# echo $temp
|
||||
oldversionfile=$temp'.version.yaml'
|
||||
echo $oldversionfile
|
||||
eval $(yaml $oldversionfile)
|
||||
|
||||
oldversion=$metadata_version
|
||||
echo $oldversion
|
||||
|
||||
`sed -i "s/$oldversion/$newversion/" $oldversionfile`
|
||||
`sed -i "s/version:[[:space:]]*$oldversion/version: {{ VERSION }}/" $file`
|
||||
|
||||
fi
|
||||
fi
|
||||
|
||||
done
|
||||
|
||||
|
Reference in New Issue
Block a user