From 5de92fdd6d495691e9cefeba68d0cd77e2306c73 Mon Sep 17 00:00:00 2001 From: Salah Aldeen Al Saleh Date: Wed, 25 Sep 2024 08:45:40 -0700 Subject: [PATCH 1/2] Ability to manage web packages in dev env --- README.md | 19 ++++++++++++++++++- dev/patches/kotsadm-web-up.yaml | 9 +++++++++ dev/scripts/common.sh | 10 ++-------- dev/scripts/up-ec.sh | 6 ++++++ dev/scripts/up.sh | 6 ++++++ 5 files changed, 41 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 13c65fd6f6..1fcfae0d99 100644 --- a/README.md +++ b/README.md @@ -83,7 +83,24 @@ cosign verify-blob --key sbom/key.pub --signature sbom/kots-sbom.tgz.sig sbom/ko ### Developing kotsadm web -Changes to the kotsadm web component are reflected in real-time, no manual steps required. +Changes to the kotsadm web component are reflected in real-time; no manual steps are required. + +However, to add, remove, or upgrade a dependency / package: + +1. Exec into the kotsadm-web container: + ```bash + make kotsadm-web-up + ``` + +1. Run the desired `yarn` commands. For example: + ```bash + yarn add + ``` + +1. When finished, exit the container: + ```bash + exit + ``` ### Developing kotsadm API diff --git a/dev/patches/kotsadm-web-up.yaml b/dev/patches/kotsadm-web-up.yaml index 4a758b3b06..0595d2f135 100644 --- a/dev/patches/kotsadm-web-up.yaml +++ b/dev/patches/kotsadm-web-up.yaml @@ -6,10 +6,19 @@ spec: hostPath: path: __PROJECT_DIR__/web type: Directory + - name: yarncache + hostPath: + path: __PROJECT_DIR__/dev/.yarncache + type: Directory containers: - name: kotsadm-web image: kotsadm-web-dev volumeMounts: - name: dev mountPath: /replicatedhq/kots/web # workdir in the container + - name: yarncache + mountPath: /replicatedhq/kots/dev/.yarncache + env: + - name: YARN_CACHE_FOLDER + value: /replicatedhq/kots/dev/.yarncache resources: ~ diff --git a/dev/scripts/common.sh b/dev/scripts/common.sh index 2a5857656e..91b1e78d45 100644 --- a/dev/scripts/common.sh +++ b/dev/scripts/common.sh @@ -113,14 +113,8 @@ function ec_build_and_load() { } function up() { - if [ "$1" == "kotsadm-web" ]; then - # Tail the logs of the new pod - newpod=$(kubectl get pods -l app=kotsadm-web --no-headers --sort-by=.metadata.creationTimestamp | awk 'END {print $1}') - kubectl logs -f $newpod --tail=100 - else - # Exec into the deployment - kubectl exec -it deployment/$(deployment $1) -- bash - fi + # Exec into the deployment + kubectl exec -it deployment/$(deployment $1) -- bash } function ec_up() { diff --git a/dev/scripts/up-ec.sh b/dev/scripts/up-ec.sh index a81b7940a7..8678110be6 100755 --- a/dev/scripts/up-ec.sh +++ b/dev/scripts/up-ec.sh @@ -12,6 +12,12 @@ if [ -z "$component" ]; then exit 1 fi +# kotsadm-web must already be up +if [ "$component" == "kotsadm-web" ]; then + ec_up $component + exit 0 +fi + # Build and load the image into the embedded cluster ec_build_and_load "$component" diff --git a/dev/scripts/up.sh b/dev/scripts/up.sh index 2a53720e5e..4a49dfd9a9 100755 --- a/dev/scripts/up.sh +++ b/dev/scripts/up.sh @@ -12,6 +12,12 @@ if [ -z "$component" ]; then exit 1 fi +# kotsadm-web must already be up +if [ "$component" == "kotsadm-web" ]; then + up $component + exit 0 +fi + # Save original state if [ ! -f "dev/patches/$component-down.yaml.tmp" ]; then kubectl get deployment $(deployment $component) -oyaml > dev/patches/$component-down.yaml.tmp From 1d4740cc469068b9de587305dce5d7766661636d Mon Sep 17 00:00:00 2001 From: Salah Aldeen Al Saleh Date: Wed, 25 Sep 2024 08:46:52 -0700 Subject: [PATCH 2/2] use spaces --- dev/scripts/down-ec.sh | 4 ++-- dev/scripts/down.sh | 4 ++-- dev/scripts/up-ec.sh | 6 +++--- dev/scripts/up.sh | 6 +++--- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/dev/scripts/down-ec.sh b/dev/scripts/down-ec.sh index c5abe2701d..82e6f81ad8 100755 --- a/dev/scripts/down-ec.sh +++ b/dev/scripts/down-ec.sh @@ -8,8 +8,8 @@ component=$1 # Check if a deployment name was provided if [ -z "$component" ]; then - echo "Error: No component name provided." - exit 1 + echo "Error: No component name provided." + exit 1 fi # Check if already down diff --git a/dev/scripts/down.sh b/dev/scripts/down.sh index 71d28790d9..2a89df3ddc 100755 --- a/dev/scripts/down.sh +++ b/dev/scripts/down.sh @@ -8,8 +8,8 @@ component=$1 # Check if a deployment name was provided if [ -z "$component" ]; then - echo "Error: No component name provided." - exit 1 + echo "Error: No component name provided." + exit 1 fi # Check if already down diff --git a/dev/scripts/up-ec.sh b/dev/scripts/up-ec.sh index 8678110be6..5f8c6c8473 100755 --- a/dev/scripts/up-ec.sh +++ b/dev/scripts/up-ec.sh @@ -8,13 +8,13 @@ component=$1 # Check if a component name was provided if [ -z "$component" ]; then - echo "Error: No component name provided." - exit 1 + echo "Error: No component name provided." + exit 1 fi # kotsadm-web must already be up if [ "$component" == "kotsadm-web" ]; then - ec_up $component + ec_up $component exit 0 fi diff --git a/dev/scripts/up.sh b/dev/scripts/up.sh index 4a49dfd9a9..4b3263f3da 100755 --- a/dev/scripts/up.sh +++ b/dev/scripts/up.sh @@ -8,13 +8,13 @@ component=$1 # Check if a component name was provided if [ -z "$component" ]; then - echo "Error: No component name provided." - exit 1 + echo "Error: No component name provided." + exit 1 fi # kotsadm-web must already be up if [ "$component" == "kotsadm-web" ]; then - up $component + up $component exit 0 fi