@@ -32,20 +32,25 @@ spec:
32
32
value : " /api/version"
33
33
- name : REQUIRED_VERSION_CONSTRAINT
34
34
value : " >=2.12 <3"
35
+ - name : ARGOCD_ROOT_PATH
36
+ value : {{ index .Values "global" "external-argo-cd" "server" "rootpath" | default "" }}
35
37
command : ["sh", "-c"]
36
38
args :
37
39
- | # shell
40
+ set -x
41
+
38
42
# Function to find Argo CD service and export its name and port
39
43
get_argocd_service_info() {
40
44
local service_info
41
45
local service_count
46
+ local service_info_file_path="/tmp/argocd_service_info.json"
42
47
43
48
# Clean labels
44
49
CLEAN_LABELS=$(echo "$ARGOCD_LABELS" | sed 's/,$//')
45
50
46
51
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')
49
54
50
55
if [ "$service_count" -eq 0 ]; then
51
56
echo "Error: No Argo CD service found matching labels '$CLEAN_LABELS' in namespace '$NAMESPACE'."
55
60
fi
56
61
57
62
# 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')
60
65
61
66
if [ -z "$SERVICE_NAME" ] || [ "$SERVICE_NAME" = "null" ] || [ -z "$SERVICE_PORT" ] || [ "$SERVICE_PORT" = "null" ]; then
62
67
echo "Error: Could not extract service name or port from the found service."
70
75
get_argocd_root_path() {
71
76
local root_path
72
77
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
75
85
76
86
if [ -n "$root_path" ] && [ "$root_path" != "/" ]; then
77
87
root_path=$(echo "$root_path" | sed 's:/*$::') # Remove trailing slash
0 commit comments