Refactor ADC install and usage in job-adc-sync script
Simplify dependency installation and ADC binary setup. Replace ADC command lookup logic with direct usage after installation.
This commit is contained in:
@@ -51,13 +51,26 @@ spec:
|
|||||||
set -e
|
set -e
|
||||||
echo "Starting API7 ADC configuration sync..."
|
echo "Starting API7 ADC configuration sync..."
|
||||||
|
|
||||||
# Install jq if needed for auto-publish feature
|
# Install dependencies and ADC binary
|
||||||
{{- if .Values.api7.autoPublish }}
|
echo "Installing curl and dependencies..."
|
||||||
if ! command -v jq &> /dev/null; then
|
if command -v apk &> /dev/null; then
|
||||||
echo "Installing jq..."
|
apk add --no-cache curl {{- if .Values.api7.autoPublish }} jq{{- end }}
|
||||||
apk add --no-cache jq curl || apt-get update && apt-get install -y jq curl || yum install -y jq curl
|
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
|
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
|
# Wait for API7 Gateway to be ready
|
||||||
echo "Waiting for API7 Gateway to be available..."
|
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
|
sed -i 's|/etc/ssl/certs/tls.key|/tmp/tls.key|g' /config/adc-config.yaml
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
|
||||||
# Find and use ADC command
|
adc validate -f /config/adc-config.yaml || {
|
||||||
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 || {
|
|
||||||
echo "ERROR: Configuration validation failed"
|
echo "ERROR: Configuration validation failed"
|
||||||
cat /config/adc-config.yaml
|
cat /config/adc-config.yaml
|
||||||
exit 1
|
exit 1
|
||||||
@@ -130,7 +123,7 @@ spec:
|
|||||||
|
|
||||||
# Sync configuration to API7
|
# Sync configuration to API7
|
||||||
echo "Syncing configuration to API7 Gateway..."
|
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" }} \
|
--backend {{ .Values.api7.backend | default "api7ee" }} \
|
||||||
--server ${API7_ADMIN_URL} \
|
--server ${API7_ADMIN_URL} \
|
||||||
--token ${API7_ADMIN_KEY} \
|
--token ${API7_ADMIN_KEY} \
|
||||||
|
|||||||
Reference in New Issue
Block a user