Skip to content

Commit 03e085c

Browse files
fix: validate-values script (#560)
1 parent ebb1c8c commit 03e085c

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

charts/gitops-runtime/templates/hooks/pre-install/validate-values.yaml

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,25 @@ spec:
3232
value: "/api/version"
3333
- name: REQUIRED_VERSION_CONSTRAINT
3434
value: ">=2.12 <3"
35+
- name: ARGOCD_ROOT_PATH
36+
value: {{ index .Values "global" "external-argo-cd" "server" "rootpath" | default "" }}
3537
command: ["sh", "-c"]
3638
args:
3739
- | # shell
40+
set -x
41+
3842
# Function to find Argo CD service and export its name and port
3943
get_argocd_service_info() {
4044
local service_info
4145
local service_count
46+
local service_info_file_path="/tmp/argocd_service_info.json"
4247
4348
# Clean labels
4449
CLEAN_LABELS=$(echo "$ARGOCD_LABELS" | sed 's/,$//')
4550
4651
echo "Searching for Argo CD service in namespace '$NAMESPACE' with labels '$CLEAN_LABELS'"
47-
service_info=$(kubectl get svc -n "$NAMESPACE" -l "$CLEAN_LABELS" -o json)
48-
service_count=$(echo "$service_info" | jq '.items | length')
52+
kubectl get svc -n "$NAMESPACE" -l "$CLEAN_LABELS" -o json > $service_info_file_path 2>/dev/null
53+
service_count=$(cat "$service_info_file_path" | jq '.items | length')
4954
5055
if [ "$service_count" -eq 0 ]; then
5156
echo "Error: No Argo CD service found matching labels '$CLEAN_LABELS' in namespace '$NAMESPACE'."
@@ -55,8 +60,8 @@ spec:
5560
fi
5661
5762
# Set global variables
58-
SERVICE_NAME=$(echo "$service_info" | jq -r '.items[0].metadata.name')
59-
SERVICE_PORT=$(echo "$service_info" | jq -r '.items[0].spec.ports[0].port')
63+
SERVICE_NAME=$(cat "$service_info_file_path" | jq -r '.items[0].metadata.name')
64+
SERVICE_PORT=$(cat "$service_info_file_path" | jq -r '.items[0].spec.ports[0].port')
6065
6166
if [ -z "$SERVICE_NAME" ] || [ "$SERVICE_NAME" = "null" ] || [ -z "$SERVICE_PORT" ] || [ "$SERVICE_PORT" = "null" ]; then
6267
echo "Error: Could not extract service name or port from the found service."
@@ -70,8 +75,13 @@ spec:
7075
get_argocd_root_path() {
7176
local root_path
7277
73-
echo "Fetching Argo CD root path from ConfigMap 'argocd-cmd-params-cm' in namespace '$NAMESPACE'..."
74-
root_path=$(kubectl get configmap "argocd-cmd-params-cm" -n "$NAMESPACE" -o jsonpath='{.data.server\.rootpath}' 2>/dev/null || echo "")
78+
if [ -z "$ARGOCD_ROOT_PATH" ]; then
79+
echo "Fetching Argo CD root path from ConfigMap 'argocd-cmd-params-cm' in namespace '$NAMESPACE'..."
80+
root_path=$(kubectl get configmap "argocd-cmd-params-cm" -n "$NAMESPACE" -o jsonpath='{.data.server\.rootpath}' 2>/dev/null || echo "")
81+
else
82+
echo "Using provided Argo CD root path: '$ARGOCD_ROOT_PATH'"
83+
root_path="$ARGOCD_ROOT_PATH"
84+
fi
7585
7686
if [ -n "$root_path" ] && [ "$root_path" != "/" ]; then
7787
root_path=$(echo "$root_path" | sed 's:/*$::') # Remove trailing slash

0 commit comments

Comments
 (0)