api-gateway: migrate YAML gen + provider core from deck-api (?endpoint=) to lk-api-gateway (REST paths)

- service_spec_gen: callAPI() auto-detects proxy vs REST mode by index.cfm presence
- core/client.go: buildURL() replaces all 4 ?endpoint= harcoded sites
- build-provider.sh: -ldflags -X main.version=${VERSION} for correct binary version
- 01_generate_yamls.sh (devops + root): Python auto-detect proxy vs REST
- 02_generate_resources_and_docs_v2.sh: pass -api-endpoint to doc generators
- 04_build_and_publish_docs.sh: normalize_api_endpoint without forced /index.cfm
- docs_template_gen + v2: -api-endpoint flag, hardcoded deck-api replaced
- provider.go (both): TODO(api-gateway) comments
- profiles/test/profile.env: NUBES_API_ENDPOINT -> lk-api-gateway-test
- HISTORY: 2026-07-02_api_gateway_migration.md
This commit is contained in:
“Naeel”
2026-07-02 12:40:47 +04:00
parent 54647b2fbf
commit 612aa53caf
13 changed files with 212 additions and 68 deletions
+8 -6
View File
@@ -106,10 +106,8 @@ if [[ ! -f "$SERVICES_FILE" ]]; then
fi
API_ENDPOINT="${NUBES_API_ENDPOINT:-https://deck-api.ngcloud.ru/api/v1/index.cfm}"
# Generator expects proxy-style endpoint (index.cfm?endpoint=/...).
if [[ "$API_ENDPOINT" != */index.cfm ]]; then
API_ENDPOINT="${API_ENDPOINT%/}/index.cfm"
fi
# Auto-detect API style: if endpoint contains "index.cfm" → legacy proxy (?endpoint=),
# otherwise → new REST gateway (direct paths). No forced /index.cfm normalization.
GENERATED_DIR="${PROFILE_DIR}/generated"
YAML_OUTPUT_DIR_DEFAULT="${GENERATED_DIR}/resources_yaml"
@@ -179,8 +177,12 @@ endpoint = "${API_ENDPOINT}"
token = "${NUBES_API_TOKEN}"
max_retries = 3
params = urllib.parse.urlencode({"endpoint": f"/services/{sid}"})
url = f"{endpoint}?{params}"
# Auto-detect API style: "index.cfm" → legacy proxy, otherwise → REST gateway.
if "index.cfm" in endpoint:
params = urllib.parse.urlencode({"endpoint": f"/services/{sid}"})
url = f"{endpoint}?{params}"
else:
url = f"{endpoint}/services/{sid}"
for attempt in range(1, max_retries + 1):
try:
+12 -1
View File
@@ -89,9 +89,20 @@ cp -R "$TMP_GEN_DIR/." "$GO_OUTPUT_DIR/"
echo "Generating docs via template generator..."
mkdir -p "$DOCS_DIR"
# Determine API endpoint for doc examples.
# Use NUBES_API_ENDPOINT from profile.env, fall back to production default.
DOCS_API_ENDPOINT="${NUBES_API_ENDPOINT:-https://deck-api.ngcloud.ru/api/v1/index.cfm}"
# If endpoint looks like new REST gateway (no index.cfm), keep as-is.
# If it's old-style without index.cfm, append it for backward compat in docs.
if [[ "$DOCS_API_ENDPOINT" != *"/index.cfm"* ]] && [[ "$DOCS_API_ENDPOINT" != *"/svc"* ]]; then
DOCS_API_ENDPOINT="${DOCS_API_ENDPOINT%/}/index.cfm"
fi
go run ./tools/docs_template_gen_v2 \
-resources "$RESOURCES_YAML_DIR" \
-docs "$DOCS_DIR" \
-services "$SERVICES_LIST_PATH"
-services "$SERVICES_LIST_PATH" \
-api-endpoint "$DOCS_API_ENDPOINT"
echo "Resources and docs generated in template format."
+3 -5
View File
@@ -13,11 +13,9 @@ normalize_api_endpoint() {
echo "https://deck-api.ngcloud.ru/api/v1/index.cfm"
return
fi
if [[ "$endpoint" == */index.cfm ]]; then
echo "$endpoint"
return
fi
echo "${endpoint}/index.cfm"
# Keep as-is: both legacy proxy (index.cfm) and new REST gateway are valid.
# No forced /index.cfm normalization — the downstream tools auto-detect.
echo "$endpoint"
}
if [[ "${1:-}" == "--profile" ]]; then
+1 -1
View File
@@ -77,7 +77,7 @@ build_and_zip() {
fi
echo "Building for ${os}/${arch}..."
(cd "$PROVIDER_DIR" && CGO_ENABLED=0 GOOS="$os" GOARCH="$arch" go build -o "${BUILD_DIR}/${binary}" .)
(cd "$PROVIDER_DIR" && CGO_ENABLED=0 GOOS="$os" GOARCH="$arch" go build -ldflags "-X main.version=${VERSION}" -o "${BUILD_DIR}/${binary}" .)
(cd "$BUILD_DIR" && python3 -m zipfile -c "terraform-provider-nubes_${VERSION}_${os}_${arch}.zip" "$binary")
rm -f "${BUILD_DIR:?}/${binary}"
+1 -1
View File
@@ -1,5 +1,5 @@
# Stand profile: TEST
NUBES_API_ENDPOINT="https://deck-api-test.ngcloud.ru/api/v1"
NUBES_API_ENDPOINT="https://lk-api-gateway-test.ngcloud.ru/api/v1/svc"
TOKEN_FILE="secrets/test.token"
# Release versions