Refactor ADC install and usage in job-adc-sync script
All checks were successful
Helm Chart Build / lint-only (push) Has been skipped
Helm Chart Build / build-helm (push) Successful in 1m10s
Build and Deploy / build-api (push) Successful in 2m20s
Build and Deploy / build-web (push) Successful in 2m36s

Simplify dependency installation and ADC binary setup. Replace ADC
command lookup logic with direct usage after installation.
This commit is contained in:
d.viti
2025-10-08 13:55:58 +02:00
parent 90c6f6fe62
commit 741117dab8

View File

@@ -51,13 +51,26 @@ spec:
set -e
echo "Starting API7 ADC configuration sync..."
# Install jq if needed for auto-publish feature
{{- if .Values.api7.autoPublish }}
if ! command -v jq &> /dev/null; then
echo "Installing jq..."
apk add --no-cache jq curl || apt-get update && apt-get install -y jq curl || yum install -y jq curl
# Install dependencies and ADC binary
echo "Installing curl and dependencies..."
if command -v apk &> /dev/null; then
apk add --no-cache curl {{- if .Values.api7.autoPublish }} jq{{- end }}
elif command -v apt-get &> /dev/null; then
apt-get update && apt-get install -y curl {{- if .Values.api7.autoPublish }} jq{{- end }}
elif command -v yum &> /dev/null; then
yum install -y curl {{- if .Values.api7.autoPublish }} jq{{- end }}
fi
{{- end }}
# Download and install ADC binary
echo "Downloading ADC binary..."
curl -sL "https://run.api7.ai/adc/install" | sh
# Verify ADC installation
if ! command -v adc &> /dev/null; then
echo "ERROR: ADC installation failed"
exit 1
fi
echo "ADC installed successfully"
# Wait for API7 Gateway to be ready
echo "Waiting for API7 Gateway to be available..."
@@ -102,27 +115,7 @@ spec:
sed -i 's|/etc/ssl/certs/tls.key|/tmp/tls.key|g' /config/adc-config.yaml
{{- end }}
# Find and use ADC command
if command -v adc &> /dev/null; then
ADC_CMD="adc"
elif [ -f /usr/local/bin/adc ]; then
ADC_CMD="/usr/local/bin/adc"
elif [ -f /usr/bin/adc ]; then
ADC_CMD="/usr/bin/adc"
elif [ -f /adc ]; then
ADC_CMD="/adc"
else
echo "ERROR: ADC command not found in container image"
echo "Available commands:"
ls -la /usr/local/bin/ /usr/bin/ / 2>/dev/null | grep adc || true
exit 1
fi
echo "Using ADC command: $ADC_CMD"
# Validate configuration
echo "Validating ADC configuration..."
$ADC_CMD validate -f /config/adc-config.yaml || {
adc validate -f /config/adc-config.yaml || {
echo "ERROR: Configuration validation failed"
cat /config/adc-config.yaml
exit 1
@@ -130,7 +123,7 @@ spec:
# Sync configuration to API7
echo "Syncing configuration to API7 Gateway..."
$ADC_CMD sync -f /config/adc-config.yaml \
adc sync -f /config/adc-config.yaml \
--backend {{ .Values.api7.backend | default "api7ee" }} \
--server ${API7_ADMIN_URL} \
--token ${API7_ADMIN_KEY} \