-
Notifications
You must be signed in to change notification settings - Fork 27
/
templates-is.sh
executable file
·55 lines (49 loc) · 1.27 KB
/
templates-is.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/bin/bash
function usage() {
echo "usage: templates-is.sh [-hf] [TAG]"
echo
echo "Copy s2i to ./templates-is and modify for use with imagestreams created with rad-image"
echo
echo "Options:"
echo " -h Print this help message"
echo " -f Force overwrite of ./templates-is"
echo " TAG Use TAG as the tag for imagestream references. Default is 'stable'"
}
FORCE=false
while getopts fh option; do
case $option in
h)
usage
exit 0
;;
f)
FORCE=true
;;
*)
;;
esac
done
shift $((OPTIND-1))
if [ "$#" -ne 1 ]; then
tag=stable
else
tag=$1
fi
if [ -d templates-is ]; then
if [ "$FORCE" == "true" ]; then
rm -rf templates-is/*
else
echo templates-is already exists, run with '-f' to overwrite
exit 1
fi
fi
mkdir -p templates-is
echo Using tag "'"$tag"'"
echo Generated:
templates=$(grep -l DockerImage templates/*.json)
for t in $templates; do
echo " "templates-is/$(basename $t)
cp $t templates-is
sed -i 's@"kind": "DockerImage"@"kind": "ImageStreamTag"@g' templates-is/$(basename $t)
sed -i -r "s@\"name\": \"radanalyticsio/(.*)\"@\"name\": \"\1:"$tag"\"@g" templates-is/$(basename $t)
done