@colisweb/rescript-toolkit 5.10.4 → 5.10.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -250,11 +250,11 @@ entries:
250
250
  cronjob:
251
251
  EOT
252
252
 
253
- # helm3 stable repo have changed and must be updated manually, in versions < v2.17.0
254
- helm3 repo add colisweb s3://colisweb-helm-charts/colisweb --force-update
255
- helm3 repo add stable https://charts.helm.sh/stable --force-update
256
- helm3 repo update
257
- helm3 dependency update ${ROOT_PATH}/${CHART_PATH}
253
+ # helm stable repo have changed and must be updated manually, in versions < v2.17.0
254
+ helm repo add colisweb s3://colisweb-helm-charts/colisweb --force-update
255
+ helm repo add stable https://charts.helm.sh/stable --force-update
256
+ helm repo update
257
+ helm dependency update ${ROOT_PATH}/${CHART_PATH}
258
258
 
259
259
  # Gather values/*.yaml files
260
260
  VALUES_PATH="${ROOT_PATH}/${CHART_NAME}/values"
@@ -262,7 +262,7 @@ EOT
262
262
  [ -d $VALUES_PATH ] && VALUES_FILES=$(find $VALUES_PATH -type f -maxdepth 1 -name "*.yaml" | sed 's/^/ -f /' | tr -d \\n | sed 's/%//')
263
263
 
264
264
  # Deploy
265
- helm3 upgrade --install \
265
+ helm upgrade --install \
266
266
  --namespace ${ENVIRONMENT} \
267
267
  ${VALUES_FILES} \
268
268
  -f ${ROOT_PATH}/${CONFIG_PATH}/common.yaml \
@@ -272,7 +272,7 @@ EOT
272
272
  ${CHART_NAME} ${ROOT_PATH}/${CHART_PATH}
273
273
 
274
274
 
275
- verify_deployments_v3 -t 10m $ENVIRONMENT $CHART_NAME
275
+ verify_deployments -t 10m $ENVIRONMENT $CHART_NAME
276
276
 
277
277
  }
278
278
 
@@ -596,7 +596,7 @@ mysql_on_k8() {
596
596
  local query=$7
597
597
 
598
598
  kubectl -n ${namespace} run ${service}-mysql-init \
599
- --image widdpim/mysql-client \
599
+ --image arey/mysql-client \
600
600
  --restart=Never \
601
601
  --attach --rm \
602
602
  -- \
@@ -612,8 +612,6 @@ kube_init_database_once() {
612
612
  echo " Initializing Database '$db_database' for namespace $namespace"
613
613
  echo "======================="
614
614
 
615
- set -x
616
-
617
615
  echo "Checking if Database '$db_database' exists"
618
616
  set +e
619
617
  psql_on_k8 $namespace once "$db_init_username:$db_init_password@$db_host:$db_port" -lqtA | cut -d\| -f1 | grep "^$db_database$"
@@ -676,14 +674,14 @@ kube_init_datadog_in_database() {
676
674
  extract_args 8 namespace db_host db_port db_init_username db_init_password db_datadog_username db_datadog_password db_datadog_schema $*
677
675
 
678
676
  echo "======================="
679
- echo " Initializing Datadog Agent Requiement for namespace $namespace"
677
+ echo " Initializing Datadog Agent Requirement for namespace $namespace"
680
678
  echo "======================="
681
679
 
682
680
  echo "Checking if User '$db_datadog_username' exists"
683
681
  local service="datadog"
684
682
  found_db_users=$(mysql_on_k8 $namespace $service $db_host $db_port $db_init_username $db_init_password 'SELECT user FROM mysql.user;')
685
683
  set +e
686
- echo $found_db_users | grep "^$db_datadog_username$"
684
+ echo "$found_db_users" | grep "^$db_datadog_username$"
687
685
  return_code=$?
688
686
  set -e
689
687
 
@@ -843,8 +841,6 @@ kube_init_service_database() {
843
841
 
844
842
  local db_connection="$db_init_username:$db_init_password@$db_host:$db_port"
845
843
 
846
- set -x
847
-
848
844
  echo "Checking if Database '$db_database' exists"
849
845
  set +e
850
846
  psql_on_k8 $namespace $service $db_connection -lqtA | cut -d\| -f1 | grep "^$db_database$"
@@ -873,6 +869,57 @@ kube_init_service_database() {
873
869
 
874
870
  #!/usr/bin/env bash
875
871
 
872
+ # Allow to use JMX connection to retrieve data and metrics from the pods within kubernetes
873
+ # You will need visualVM to use this tool https://visualvm.github.io/
874
+ # ex: bind_jmx testing notification
875
+ bind_jmx() {
876
+
877
+ local ENV=$1
878
+ local SERVICE_NAME=$2
879
+ local PORT=2242
880
+
881
+ start_ssh_bastion $ENV $PORT
882
+
883
+ echo "root" | ssh -f -N -oUserKnownHostsFile=/dev/null -oStrictHostKeyChecking=no -D 7777 root@127.0.0.1 -p 2242
884
+ local PODS=$(kubectl -n $ENV get pods -o wide | grep $SERVICE_NAME | grep -Eo '^[^ ]+')
885
+
886
+ echo "Choose one of the following pod to get metrics from..."
887
+ local POD_NAME=$(gum choose $PODS)
888
+ local POD_IP=$(
889
+ kubectl -n $ENV get pods -o jsonpath='{range .items[*]}{.metadata.name}{" "}{.status.podIP}{"\n"}{end}' |
890
+ grep $POD_NAME |
891
+ cut -d' ' -f2 |
892
+ head -1
893
+ )
894
+
895
+ jconsole -J-DsocksProxyHost=localhost \
896
+ -J-DsocksProxyPort=7777 \
897
+ service:jmx:rmi:///jndi/rmi://$POD_IP:7199/jmxrmi \
898
+ -J-DsocksNonProxyHosts= &
899
+
900
+ cat << EOF
901
+ Now start VisualVM
902
+ Preferences > Network > Manual Proxy Settings
903
+ SOCKS Proxy Line: Set 'localhost' and Port '7777'
904
+ File > Add JMX Connection
905
+ Set $POD_IP:7199, check 'do not require an SSL connection'
906
+ Remember to kill you bastion afterward using 'stop_ssh_bastion'
907
+ EOF
908
+ }
909
+ #!/usr/bin/env bash
910
+
911
+ k8_nodes_stats() {
912
+ kubectl get nodes -o name |
913
+ xargs kubectl describe |
914
+ grep "^Name\|workType\|cpu \|memory " |
915
+ sed -r 's/[ :=]+/\t/g' |
916
+ sed 's/\tworkType\t//g' |
917
+ sed -r 's/^Name/---\nName/g' |
918
+ grep --color "Name\|web\|workers\|cpu\|memory\|---"
919
+ }
920
+
921
+ #!/usr/bin/env bash
922
+
876
923
  # Port forward on the first matching pod
877
924
  # Ex :
878
925
  # pod_forward testing notification-http
@@ -1857,11 +1904,11 @@ datadog_schedule_downtime_single() {
1857
1904
  {
1858
1905
  "active": true,
1859
1906
  "downtime_type": 0,
1860
- "start": $START,
1861
- "end": $END,
1862
- "message": "CA Deployment - performance for $SERVICE may be lower for next $DOWNTIME_MINUTES min",
1907
+ "start": '$START',
1908
+ "end": '$END',
1909
+ "message": "CA Deployment - performance for '$SERVICE' may be lower for next '$DOWNTIME_MINUTES' min",
1863
1910
  "monitor_tags": [
1864
- "service:$SERVICE",
1911
+ "service:'$SERVICE'",
1865
1912
  "performance"
1866
1913
  ],
1867
1914
  "scope": [
@@ -1871,11 +1918,13 @@ datadog_schedule_downtime_single() {
1871
1918
  }
1872
1919
  '
1873
1920
  }
1921
+
1874
1922
  #!/usr/bin/env bash
1875
1923
 
1876
1924
  docker_build_push() {
1877
1925
  read -r -a BUILD_ARGS <<< "$1"
1878
1926
  DOCKER_BUILD_ARGS="--build-arg VCS_REF=$(git rev-parse --short HEAD)"
1927
+
1879
1928
  for ARG_NAME in "${BUILD_ARGS[@]}"
1880
1929
  do
1881
1930
  DOCKER_BUILD_ARGS="$DOCKER_BUILD_ARGS --build-arg $ARG_NAME=${!ARG_NAME}"
@@ -1884,13 +1933,17 @@ docker_build_push() {
1884
1933
  if ! image_exists $DOCKER_REGISTRY_ID $APPLICATION $CI_COMMIT_SHORT_SHA ; then
1885
1934
  docker pull $DOCKER_IMAGE || true
1886
1935
  SOURCE_URL=${CI_PROJECT_URL:8} # without "https://" protocol, like gitlab.com/colisweb-idl/colisweb/back/packing
1887
- docker build $DOCKER_BUILD_ARGS \
1936
+
1937
+ docker buildx create --use
1938
+
1939
+ docker buildx build $DOCKER_BUILD_ARGS \
1888
1940
  -t $DOCKER_IMAGE_SHA \
1941
+ --platform "linux/arm64,linux/amd64" \
1889
1942
  --label org.opencontainers.image.revision=$(git rev-parse HEAD) \
1890
1943
  --label org.opencontainers.image.source=$SOURCE_URL \
1891
- --cache-from $DOCKER_IMAGE \
1944
+ --provenance=false \
1945
+ --push \
1892
1946
  $DOCKER_STAGE_PATH
1893
- docker push $DOCKER_IMAGE_SHA
1894
1947
  fi
1895
1948
  }
1896
1949
 
@@ -2026,7 +2079,7 @@ init_migrate_db() {
2026
2079
 
2027
2080
  unset KUBECONFIG
2028
2081
 
2029
- configure_kubectl_for_ci ${ENVIRONMENT}
2082
+ configure_kubectl_for ${ENVIRONMENT}
2030
2083
 
2031
2084
  kube_init_service_database \
2032
2085
  --namespace ${ENVIRONMENT} \
@@ -2072,7 +2125,7 @@ flyway_migrate() {
2072
2125
  CONFIGMAP_NAME="$service-flyway-migration-sql"
2073
2126
  POD_NAME="$service-flyway-migration"
2074
2127
 
2075
- configure_kubectl_for_ci $environment
2128
+ configure_kubectl_for $environment
2076
2129
 
2077
2130
  kubectl -n $namespace delete configmap $CONFIGMAP_NAME --ignore-not-found
2078
2131
  kubectl -n $namespace delete pod $POD_NAME --ignore-not-found
@@ -2125,7 +2178,7 @@ flyway_migrate() {
2125
2178
 
2126
2179
  flyway_sql_folder=$(pwd)/${MIGRATION_SQL_PATH}
2127
2180
 
2128
- configure_kubectl_for_ci "${ENVIRONMENT}"
2181
+ configure_kubectl_for "${ENVIRONMENT}"
2129
2182
  POD_NAME="${APPLICATION}-flyway-repair"
2130
2183
  CONFIGMAP_NAME="${APPLICATION}-flyway-repair-sql"
2131
2184
 
@@ -2191,11 +2244,11 @@ git_reveal() {
2191
2244
  }
2192
2245
  #!/usr/bin/env bash
2193
2246
 
2194
- helm_deploy_v3() {
2247
+ helm_deploy() {
2195
2248
  APPLICATION=$1
2196
2249
  ENVIRONMENT=$2
2197
2250
  VERSION=$3
2198
- deploy_chart_v3 \
2251
+ deploy_chart \
2199
2252
  --path_configs deploy \
2200
2253
  --path_chart deploy/$APPLICATION \
2201
2254
  --application $APPLICATION \
@@ -2204,7 +2257,7 @@ helm_deploy_v3() {
2204
2257
  --helm_extra_args --set global.version=$VERSION
2205
2258
  }
2206
2259
 
2207
- deploy_chart_v3() {
2260
+ deploy_chart() {
2208
2261
  set -e
2209
2262
  set -x
2210
2263
 
@@ -2251,15 +2304,15 @@ deploy_chart_v3() {
2251
2304
  unset KUBECONFIG
2252
2305
 
2253
2306
  # Configure Kubectl
2254
- configure_kubectl_for_ci ${environment}
2307
+ configure_kubectl_for ${environment}
2255
2308
 
2256
- # Configure helm3
2257
- helm3 version --namespace ${namespace} || true
2258
- # helm3 stable repo have changed and must be updated manually, in versions < v2.17.0
2259
- helm3 repo add colisweb s3://colisweb-helm-charts/colisweb
2260
- helm3 repo add stable https://charts.helm.sh/stable
2261
- helm3 repo update
2262
- helm3 dependency update ${root_path}/${path_chart}
2309
+ # Configure helm
2310
+ helm version --namespace ${namespace} || true
2311
+ # helm stable repo have changed and must be updated manually, in versions < v2.17.0
2312
+ helm repo add colisweb s3://colisweb-helm-charts/colisweb
2313
+ helm repo add stable https://charts.helm.sh/stable
2314
+ helm repo update
2315
+ helm dependency update ${root_path}/${path_chart}
2263
2316
 
2264
2317
  # Gather values/*.yaml files
2265
2318
  values_path="${root_path}/${path_chart}/values"
@@ -2267,7 +2320,7 @@ deploy_chart_v3() {
2267
2320
  [ -d $values_path ] && values_files=$(find $values_path -type f -maxdepth 1 -name "*.yaml" | sed 's/^/ -f /' | tr -d \\n | sed 's/%//')
2268
2321
 
2269
2322
  # Deploy
2270
- helm3 upgrade --install \
2323
+ helm upgrade --install \
2271
2324
  --namespace ${namespace} \
2272
2325
  ${values_files} \
2273
2326
  -f ${root_path}/${path_configs}/common.yaml \
@@ -2289,7 +2342,7 @@ deploy_chart_v3() {
2289
2342
  set +x
2290
2343
  }
2291
2344
 
2292
- verify_deployments_v3() {
2345
+ verify_deployments() {
2293
2346
  set -e
2294
2347
 
2295
2348
  # usage :
@@ -2309,7 +2362,7 @@ verify_deployments_v3() {
2309
2362
 
2310
2363
  # Get all Deployments names from the deployed chart
2311
2364
  DEPLOYMENTS=(
2312
- $(helm3 get manifest --namespace $NAMESPACE $RELEASE | yq -rs '.[] | select(.kind=="Deployment") | .metadata.name')
2365
+ $(helm get manifest --namespace $NAMESPACE $RELEASE | yq --no-doc -r 'select(.kind=="Deployment").metadata.name')
2313
2366
  )
2314
2367
 
2315
2368
  echo "verifying on $NAMESPACE deployments ${DEPLOYMENTS[@]} with a timeout of $TIMEOUT"
@@ -2352,40 +2405,6 @@ check_config_file() {
2352
2405
  fi
2353
2406
  }
2354
2407
 
2355
- #!/usr/bin/env bash
2356
-
2357
- configure_kubectl_for_ci() {
2358
- if [ -z ${GITLAB_PAT} ]; then
2359
- echo "Cannot configure kubectl: no GITLAB_PAT configured"
2360
- exit 1
2361
- fi
2362
-
2363
- infra_env="$1"
2364
- valid_envs="[testing][staging][production][performance][tests][recette]"
2365
- echo "$valid_envs" | grep -q "\[$infra_env\]"
2366
-
2367
- if [ $? -ne 0 ]; then
2368
- echo "Cannot configure kubectl for invalid env : $infra_env"
2369
- echo "choose one of $valid_envs"
2370
- exit 1
2371
- fi
2372
-
2373
- mkdir -p ~/.kube
2374
- curl -fsS \
2375
- --header "PRIVATE-TOKEN: $GITLAB_PAT" \
2376
- "https://gitlab.com/api/v4/projects/8141053/jobs/artifacts/$infra_env/raw/$infra_env.kubeconfig?job=4_kubernetes_config_output" \
2377
- > ~/.kube/$infra_env.kubeconfig
2378
-
2379
- curl_return_code=$?
2380
- if [ ${curl_return_code} -ne 0 ]; then
2381
- echo "Cannot configure kubectl for $infra_env, get configuration failed with code $curl_return_code"
2382
- exit ${curl_return_code}
2383
- fi
2384
-
2385
- rm -f ~/.kube/config
2386
- ln -s ~/.kube/$infra_env.kubeconfig ~/.kube/config
2387
- echo "Configured kubectl for env : $infra_env"
2388
- }
2389
2408
  notify_new_deployment() {
2390
2409
  jq --version || (apt update && apt install -y jq)
2391
2410
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@colisweb/rescript-toolkit",
3
- "version": "5.10.4",
3
+ "version": "5.10.5",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "clean": "rescript clean",
@@ -49,8 +49,8 @@ let colorStyle = (~color: color, ~variant, ~disabled) =>
49
49
  }
50
50
  | #text =>
51
51
  switch color {
52
+ | #white => "uppercase text-white hover:bg-gray-100 hover:text-gray-800 disabled:bg-gray-200"
52
53
  | #black
53
- | #white
54
54
  | #gray => "uppercase text-gray-800 hover:bg-gray-100 disabled:bg-gray-200"
55
55
  | #success => "uppercase text-success-600 hover:bg-success-50 disabled:bg-success-50"
56
56
  | #info => "uppercase text-info-600 hover:bg-info-50 disabled:bg-info-50"