-
Notifications
You must be signed in to change notification settings - Fork 545
Expand file tree
/
Copy pathupdate-codegen.sh
More file actions
executable file
·41 lines (33 loc) · 1.24 KB
/
update-codegen.sh
File metadata and controls
executable file
·41 lines (33 loc) · 1.24 KB
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
SOURCE_PLUGIN_DIRS=$(ls plugins/source)
DESTINATION_PLUGIN_DIRS=$(ls plugins/destination)
TRANSFORMER_PLUGIN_DIRS=$(ls plugins/transformer)
# append source / destination prefixes
SOURCE_PLUGIN_DIRS=$(echo $SOURCE_PLUGIN_DIRS | tr ' ' '\n' | sed 's/^/source\//g' | tr '\n' ' ')
DESTINATION_PLUGIN_DIRS=$(echo $DESTINATION_PLUGIN_DIRS | tr ' ' '\n' | sed 's/^/destination\//g' | tr '\n' ' ')
TRANSFORMER_PLUGIN_DIRS=$(echo $TRANSFORMER_PLUGIN_DIRS | tr ' ' '\n' | sed 's/^/transformer\//g' | tr '\n' ' ')
PLUGIN_DIRS="$SOURCE_PLUGIN_DIRS $DESTINATION_PLUGIN_DIRS $TRANSFORMER_PLUGIN_DIRS"
echo "Updating codegen for plugins: $PLUGIN_DIRS"
PARALLEL_EXISTS=$(which parallel)
generate() {
plugin=$1
if ! grep -q "gen:" "plugins/$plugin/Makefile"; then
echo "no gen target found for $plugin"
return
fi
echo "updating modules for $plugin"
if [ -d "plugins/$plugin/vendor" ]; then
(cd "plugins/$plugin" && go mod tidy && go mod vendor)
else
(cd "plugins/$plugin" && go mod tidy)
fi
echo "Generating code for $plugin"
(cd "plugins/$plugin" && make gen)
}
if [ -z "$PARALLEL_EXISTS" ]; then
for plugin in $PLUGIN_DIRS; do
generate $plugin
done
exit 0
fi
export -f generate
echo $PLUGIN_DIRS | tr ' ' '\n' | parallel -j 8 generate