This repository has been archived by the owner on Nov 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathupdate-resources.sh
executable file
·173 lines (142 loc) · 8.53 KB
/
update-resources.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
#!/bin/bash
echo "MAKE SURE YOU ARE ON LATEST MAIN"
echo "Do you want to download the latest zip of Kaoto bridged camel components(main of camel-component-metadata)? (y/n)"
read -r download
path=$(pwd)
if [ "$download" = "y" ];
then
echo "Removing old zip files"
git rm api/src/main/resources/camel-component-metadata.zip
git rm camel-support/src/test/resources/camel-component-metadata.zip
echo "Downloading Kaoto bridged Camel components (EIP)."
wget https://github.com/KaotoIO/camel-component-metadata/archive/refs/heads/main.zip
cp "main.zip" "${path}/api/src/main/resources/camel-component-metadata.zip"
mv "main.zip" "${path}/camel-support/src/test/resources/camel-component-metadata.zip"
git add -f api/src/main/resources/camel-component-metadata.zip
git add -f camel-support/src/test/resources/camel-component-metadata.zip
echo "Updating version info in Readme"
commitHash=$(git ls-remote https://github.com/KaotoIO/camel-component-metadata HEAD | head -n1 | awk '{print $1;}')
sed -i 's/camel components: \*\*.*/camel components: \*\*'"$commitHash"'\*\*/g' README.md
git add README.md
fi
echo "Do you want to download the latest Kaoto view definitions (main of kaoto-viewdefinition-catalog)? (y/n)"
read -r download
if [ "$download" = "y" ];
then
path=$(pwd)
echo "Removing old zip files"
git rm api/src/main/resources/view-definition.zip
git rm camel-support/src/test/resources/view-definition.zip
echo "Downloading Kaoto view definitions."
wget https://github.com/KaotoIO/kaoto-viewdefinition-catalog/archive/refs/heads/main.zip
cp "main.zip" "${path}/api/src/main/resources/view-definition.zip"
mv "main.zip" "${path}/camel-support/src/test/resources/view-definition.zip"
git add -f api/src/main/resources/view-definition.zip
git add -f camel-support/src/test/resources/view-definition.zip
echo "Updating version info in Readme"
commitHash=$(git ls-remote https://github.com/KaotoIO/kaoto-viewdefinition-catalog HEAD | head -n1 | awk '{print $1;}')
sed -i 's/view definitions: \*\*.*/view definitions: \*\*'"$commitHash"'\*\*/g' README.md
git add README.md
fi
echo "Do you want to update the Apache Camel components? (y/n)"
read -r download
if [ "$download" = "y" ];
then
echo "Downloading camel connectors."
echo "Enter camel version to use (tag in apache/camel repo):"
echo "Example: 3.21.0"
read -r versionCamel
echo "Removing old zip files"
git rm api/src/main/resources/camel-connectors-*.zip
git rm camel-support/src/test/resources/camel-connectors-*.zip
echo "Preparing zip file with camel component metadata"
cd /tmp || exit 1
mkdir camel-connectors
cd camel-connectors || exit 1
wget "https://github.com/apache/camel/archive/refs/tags/camel-${versionCamel}.zip"
unzip ./camel-"${versionCamel}".zip
cp "camel-camel-${versionCamel}/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/schema/camel-yaml-dsl.json" "${path}/camel-support/src/main/resources/io/kaoto/backend/camel/service/deployment/generator/camelroute/camel-yaml-dsl.json"
cd "camel-camel-${versionCamel}/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/" || exit 1
zip "camel-connectors-${versionCamel}.zip" ./*.json
echo "Copy new zip to Kaoto-backend"
cp "camel-connectors-${versionCamel}.zip" "${path}/api/src/main/resources/"
mv "camel-connectors-${versionCamel}.zip" "${path}/camel-support/src/test/resources/"
cd "${path}" || exit 1
echo "Updating configurations"
git add -f "${path}/api/src/main/resources/camel-connectors-${versionCamel}.zip"
git add -f "${path}/camel-support/src/test/resources/camel-connectors-${versionCamel}.zip"
sed -i 's/camel-connectors-.*/camel-connectors-'"$versionCamel"'.zip$"/g' api/src/main/resources/resources-config.json
sed -i 's/camel-connectors-.*/camel-connectors-'"$versionCamel"'.zip"/g' api/src/main/resources/application.yaml
sed -i 's/camel-connectors-.*/camel-connectors-'"$versionCamel"'.zip"/g' api/src/test/resources/application.yaml
sed -i 's/camel-connectors-.*/camel-connectors-'"$versionCamel"'.zip"/g' camel-support/src/test/resources/application.yaml
sed -i 's/camel-connectors-.*/camel-connectors-'"$versionCamel"'.zip";/g' camel-support/src/test/java/io/kaoto/backend/camel/metadata/parser/step/camelroute/CamelRouteParseCatalogTest.java
sed -i 's/VERSION = ".*/VERSION = "'"$versionCamel"'";/g' camel-support/src/test/java/io/kaoto/backend/camel/service/step/parser/kamelet/KameletStepParserServiceTest.java
sed -i 's/CAMEL_CONNECTORS_VERSION = ".*/CAMEL_CONNECTORS_VERSION = "'"$versionCamel"'";/g' camel-support/src/test/java/io/kaoto/backend/api/metadata/catalog/StepCatalogTest.java
git add api/src/main/resources/resources-config.json api/src/main/resources/application.yaml \
api/src/test/resources/application.yaml camel-support/src/test/resources/application.yaml \
camel-support/src/test/java/io/kaoto/backend/camel/metadata/parser/step/camelroute/CamelRouteParseCatalogTest.java \
camel-support/src/main/resources/io/kaoto/backend/camel/service/deployment/generator/camelroute/camel-yaml-dsl.json \
camel-support/src/test/java/io/kaoto/backend/camel/service/step/parser/kamelet/KameletStepParserServiceTest.java \
camel-support/src/test/java/io/kaoto/backend/api/metadata/catalog/StepCatalogTest.java
echo "Updating version info in Readme"
sed -i 's/Camel-connectors: \*\*.*/Camel-connectors: \*\*'"$versionCamel"'\*\*/g' README.md
git add README.md
rm -rf /tmp/camel-connectors
fi
echo "Do you want to update the Apache Camel Kamelets? (y/n)"
read -r download
if [ "$download" = "y" ];
then
echo "Downloading kamelets."
echo "Enter kamelets version to use (tag without 'v' in apache/camel-kamelets repo):"
echo "Example: 3.21.0"
read -r versionKamelets
echo "Removing old zip files"
git rm api/src/main/resources/camel-kamelets-*.jar
git rm camel-support/src/test/resources/camel-kamelets-*.jar
echo "Preparing zip file with camel component metadata"
cd /tmp || exit 1
mkdir kamelets
cd kamelets || exit 1
wget "https://github.com/apache/camel-kamelets/archive/refs/tags/v${versionKamelets}.zip"
unzip ./v"${versionKamelets}".zip
cd "camel-kamelets-${versionKamelets}/kamelets/" || exit 1
zip "camel-kamelets-${versionKamelets}.jar" ./*
echo "Copy new zip to Kaoto-backend"
cp "camel-kamelets-${versionKamelets}.jar" "${path}/api/src/main/resources/"
mv "camel-kamelets-${versionKamelets}.jar" "${path}/camel-support/src/test/resources/"
cd "${path}" || exit 1
echo "Updating configurations"
git add -f "${path}/api/src/main/resources/camel-kamelets-${versionKamelets}.jar"
git add -f "${path}/camel-support/src/test/resources/camel-kamelets-${versionKamelets}.jar"
sed -i 's/camel-kamelets-.*/camel-kamelets-'"$versionKamelets"'.jar$"/g' api/src/main/resources/resources-config.json
sed -i 's/camel-kamelets-.*/camel-kamelets-'"$versionKamelets"'.jar"/g' api/src/main/resources/application.yaml
sed -i 's/camel-kamelets-.*/camel-kamelets-'"$versionKamelets"'.jar"/g' api/src/test/resources/application.yaml
sed -i 's/camel-kamelets-.*/camel-kamelets-'"$versionKamelets"'.jar"/g' camel-support/src/test/resources/application.yaml
sed -i 's/VERSION = ".*/VERSION = "'"$versionKamelets"'";/g' camel-support/src/test/java/io/kaoto/backend/camel/metadata/parser/step/kamelet/KameletParseCatalogTest.java
sed -i 's/KAMELET_VERSION = ".*/KAMELET_VERSION = "'"$versionKamelets"'";/g' camel-support/src/test/java/io/kaoto/backend/api/metadata/catalog/StepCatalogTest.java
git add api/src/main/resources/resources-config.json api/src/main/resources/application.yaml \
api/src/test/resources/application.yaml camel-support/src/test/resources/application.yaml \
camel-support/src/test/java/io/kaoto/backend/camel/metadata/parser/step/kamelet/KameletParseCatalogTest.java \
camel-support/src/test/java/io/kaoto/backend/api/metadata/catalog/StepCatalogTest.java
echo "Updating version info in Readme"
sed -i 's/Camel-kamelets: \*\*.*/Camel-kamelets: \*\*'"$versionKamelets"'\*\*/g' README.md
git add README.md
rm -rf /tmp/kamelets
fi
echo "All resources were updated successfully!"
Yellow='\033[1;33m'
NC='\033[0m'
echo -e "${Yellow}[WARNING] If updated resources are adding some new steps, you will need to update the number of steps manually in test classes (StepCatalogTest, StepResourceTestAbstract)${NC}"
echo "Do you want to create commit automatically? (y/n)"
read -r download
if [ "$download" = "y" ];
then
git commit -m "chore(resources): Updating zip files with step catalog components."
fi
echo "Do you want to run tests? (y/n)"
read -r download
if [ "$download" = "y" ];
then
./mvnw clean test
fi