-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate_config_maps.sh
executable file
·62 lines (51 loc) · 1.76 KB
/
create_config_maps.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
#!/bin/bash
if [ "$#" -ne 1 ]; then
echo "Usage: $0 namespace_or_build_target"
echo "Example: $0 jupyterhub-dev-ns"
exit 1
fi
INPUT=$1
# Define default namespace and valid build targets
DEFAULT_NAMESPACE="jupyterhub-dev-ns"
VALID_BUILD_TARGETS=("cas" "c9088" "hub" "elter")
# Determine if the input is a namespace or build target
if [[ " ${VALID_BUILD_TARGETS[@]} " =~ " $INPUT " ]]; then
BUILD_TARGET=$INPUT
NAMESPACE=$DEFAULT_NAMESPACE
else
BUILD_TARGET="hub"
NAMESPACE=$INPUT
fi
BASE_DIR="./dist_$BUILD_TARGET"
# Run npm commands
if [ -n "$BUILD_TARGET" ]; then
echo "Running build for target: $BUILD_TARGET"
npm install
npm run build:$BUILD_TARGET
else
echo "Using namespace: $NAMESPACE"
npm install
npm run build
fi
# Create ConfigMaps
create_configmap() {
local name=$1
local path=$2
# Don't delete ConfigMaps from the cluster automatically
if [ "$NAMESPACE" = "$DEFAULT_NAMESPACE" ]; then
kubectl delete configmap $name --namespace $NAMESPACE --ignore-not-found
kubectl create configmap $name --from-file=$path --namespace $NAMESPACE
else
# Creating the ConfigMaps locally
kubectl create configmap $name --from-file=$path --dry-run=client -o json > $name.json
kubectl patch --local -f $name.json --type=json -p='[{"op": "remove", "path": "/metadata/creationTimestamp"}]' -o yaml > $name.yaml
rm $name.json
fi
}
create_configmap "static-files" "$BASE_DIR"
create_configmap "static-files-js" "$BASE_DIR/static/custom-js"
create_configmap "static-files-css" "$BASE_DIR/static/custom-css"
create_configmap "static-files-woff" "$BASE_DIR/static/woff"
create_configmap "static-files-woff2" "$BASE_DIR/static/woff2"
create_configmap "static-files-images" "$BASE_DIR/static/custom-images"
echo "All ConfigMaps processed successfully."