-
Notifications
You must be signed in to change notification settings - Fork 0
/
plugin
executable file
·77 lines (63 loc) · 1.37 KB
/
plugin
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
#!/usr/bin/env -S bash -l
set -euo pipefail
init_asdf() {
# if no .tool-versions found return function early
if [[ ! -f ".tool-versions" ]]; then
return
fi
echo "Initializing asdf..."
# try to install additional tools
error=$(asdf install)
errorcode=$?
# if there are missing plugins, install them and try again
if [[ $errorcode -ne 0 ]]; then
case $error in
*"plugin is not installed"*)
missing_plugins=$(echo "$error" | awk '{ print $1 }')
for plugin in $missing_plugins; do
asdf plugin add "$plugin"
done
asdf install
;;
*)
echo "Error installing dependencies: $error"
exit 1
;;
esac
fi
echo "asdf initialization complete"
}
init_python() {
if [[ ! -f "requirements.txt" ]]; then
return
fi
echo "Initializing python..."
pip install -r requirements.txt
echo "Python initialization complete"
}
init() {
init_asdf
init_python
}
generate() {
kustomize build --enable-alpha-plugins --enable-exec --load-restrictor LoadRestrictionsNone
}
main() {
case "$1" in
"init")
init
;;
"generate")
generate
;;
*)
echo "Unknown command: $1"
echo "Usage: $0 <init|generate>"
echo ""
echo "init: install dependencies"
echo "generate: generate kustomize output"
exit 1
;;
esac
}
main "$@"