-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkedge.sh
executable file
·67 lines (55 loc) · 1.2 KB
/
kedge.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
#!/bin/bash
set -eu
usage() {
cat << EOF
This plugin provides integration with the kedge project.
Available Commands:
build Build the Kedge files into Kubernetes artifacts, but don't package.
package Generated a packaged Helm chart.
Typical usage:
$ draft kedge initialize <app name> <kedge file>
$ draft up
$ draft connect
To apply changes made to Kedge files:
$ draft kedge update <app name> <kedge file>
EOF
}
initialize() {
mkdir -p charts/$1
helm create charts/$1
rm -rf charts/$1/templates/*
echo > charts/$1/values.yaml
cat > draft.toml << EOF
[environments]
[environments.development]
name = "$1"
wait = false
namespace = "$(kubectl get secret $(kubectl get sa default -o jsonpath='{.secrets[0].name}') -o jsonpath='{.data.namespace}' | base64 -d)"
watch = false
watch_delay = 2
EOF
update $1 $2
}
update() {
kedge generate -f $2 > charts/$1/templates/kedge-generated.yaml
}
if [[ $# < 1 ]]; then
echo "===> ERROR: Subcommand required. Try 'draft kedge help'"
exit 1
fi
case "${1:-"help"}" in
"update")
update $2 $3
;;
"initialize")
initialize $2 $3
;;
"help")
usage
;;
*)
echo $1
usage
exit 1
;;
esac