forked from deckhouse/sds-replicated-volume
-
Notifications
You must be signed in to change notification settings - Fork 0
/
enabled
executable file
·38 lines (32 loc) · 1.67 KB
/
enabled
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
#!/bin/bash
source /deckhouse/shell_lib.sh
function __main__() {
enabled::disable_module_if_cluster_is_not_bootstraped
enabled::disable_module_in_kubernetes_versions_less_than 1.23.0
if values::array_has global.enabledModules "linstor" ; then
echo "You must disable the linstor module for the module to work."
echo "false" > "$MODULE_ENABLED_RESULT"
exit 0
fi
if [ "$(kubectl get moduleconfig linstor -o jsonpath={.spec.settings.dataNodes})" ]; then
linstor_settings=$(kubectl get moduleconfig linstor -o jsonpath={.spec.settings.dataNodes})
sds_drbd_settings=$(kubectl get moduleconfig sds-drbd -o jsonpath={.spec.settings.dataNodes})
if [ "$linstor_settings" != "$sds_drbd_settings" ]; then
if [ -z "$(kubectl get moduleconfig sds-drbd -o jsonpath={.spec.version})" ]; then
kubectl patch moduleconfig sds-drbd --type=json -p '[{op: "add", path: "/spec/version", value: 1}]'
fi
if [ -z "$(kubectl get moduleconfig sds-drbd -o jsonpath={.spec.settings})" ]; then
kubectl patch moduleconfig sds-drbd --type=json -p "$(kubectl get moduleconfig linstor -o json | jq '[{op: "add", path: "/spec/settings", value: .spec.settings}]')"
else
kubectl patch moduleconfig sds-drbd --type=json -p "$(kubectl get moduleconfig linstor -o json | jq '[{op: "replace", path: "/spec/settings/dataNodes", value: .spec.settings.dataNodes}]')"
fi
fi
fi
if ! values::array_has global.enabledModules "sds-node-configurator" ; then
echo "You must enable the sds-node-configurator module for the module to work."
echo "false" > "$MODULE_ENABLED_RESULT"
else
echo "true" > "$MODULE_ENABLED_RESULT"
fi
}
enabled::run $@