-
Notifications
You must be signed in to change notification settings - Fork 4
/
enabled
executable file
·53 lines (46 loc) · 2.66 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/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 this module to work."
echo "false" > "$MODULE_ENABLED_RESULT"
exit 0
fi
if values::array_has global.enabledModules "sds-drbd" ; then
echo "You must disable the sds-drbd module for this module to work."
echo "false" > "$MODULE_ENABLED_RESULT"
exit 0
fi
if [ "$(kubectl get moduleconfig sds-drbd -o jsonpath={.spec.settings.dataNodes})" ]; then
sds_drbd_settings=$(kubectl get moduleconfig sds-drbd -o jsonpath={.spec.settings.dataNodes})
sds_replicated_volume_settings=$(kubectl get moduleconfig sds-replicated-volume -o jsonpath={.spec.settings.dataNodes})
if [ "$sds_drbd_settings" != "$sds_replicated_volume_settings" ]; then
if [ -z "$(kubectl get moduleconfig sds-replicated-volume -o jsonpath={.spec.version})" ]; then
kubectl patch moduleconfig sds-replicated-volume --type=json -p '[{op: "add", path: "/spec/version", value: 1}]'
fi
if [ -z "$(kubectl get moduleconfig sds-replicated-volume -o jsonpath={.spec.settings})" ]; then
kubectl patch moduleconfig sds-replicated-volume --type=json -p "$(kubectl get moduleconfig sds-drbd -o json | jq '[{op: "add", path: "/spec/settings", value: .spec.settings}]')"
fi
fi
elif [ "$(kubectl get moduleconfig linstor -o jsonpath={.spec.settings.dataNodes})" ]; then
linstor_settings=$(kubectl get moduleconfig linstor -o jsonpath={.spec.settings.dataNodes})
sds_replicated_volume_settings=$(kubectl get moduleconfig sds-replicated-volume -o jsonpath={.spec.settings.dataNodes})
if [ "$linstor_settings" != "$sds_replicated_volume_settings" ]; then
if [ -z "$(kubectl get moduleconfig sds-replicated-volume -o jsonpath={.spec.version})" ]; then
kubectl patch moduleconfig sds-replicated-volume --type=json -p '[{op: "add", path: "/spec/version", value: 1}]'
fi
if [ -z "$(kubectl get moduleconfig sds-replicated-volume -o jsonpath={.spec.settings})" ]; then
kubectl patch moduleconfig sds-replicated-volume --type=json -p "$(kubectl get moduleconfig linstor -o json | jq '[{op: "add", path: "/spec/settings", value: .spec.settings}]')"
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 $@