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:
@@ -78,6 +78,7 @@ func main() {
|
||||
servicesListFlag := flag.String("services", "", "Path to devops/config/services_list.txt")
|
||||
excludeFlag := flag.String("exclude", "clickhouse", "Comma-separated resource names to skip")
|
||||
versionFlag := flag.String("version", "", "Provider version for example block")
|
||||
apiEndpointFlag := flag.String("api-endpoint", "https://deck-api.ngcloud.ru/api/v1/index.cfm", "API endpoint for example block")
|
||||
flag.Parse()
|
||||
|
||||
root := detectRoot()
|
||||
@@ -89,6 +90,7 @@ func main() {
|
||||
if version == "" {
|
||||
version = detectVersion(filepath.Join(root, "universal_rebuild", "main.go"))
|
||||
}
|
||||
apiEndpoint := *apiEndpointFlag
|
||||
|
||||
servicesOrder := loadServicesList(servicesList)
|
||||
specs := loadSpecs(resourcesDir, servicesOrder)
|
||||
@@ -105,7 +107,7 @@ func main() {
|
||||
if excludeSet[spec.Name] {
|
||||
continue
|
||||
}
|
||||
writeResourceDocs(docsDir, spec, version)
|
||||
writeResourceDocs(docsDir, spec, version, apiEndpoint)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -222,12 +224,12 @@ func loadSpecs(dir string, ordered []ServiceMeta) []ServiceSpec {
|
||||
return specs
|
||||
}
|
||||
|
||||
func writeResourceDocs(docsDir string, spec ServiceSpec, version string) {
|
||||
func writeResourceDocs(docsDir string, spec ServiceSpec, version string, apiEndpoint string) {
|
||||
base := spec.Name
|
||||
nav := fmt.Sprintf("[Manual](%s.md) | [Create params](%s_params_create.md) | [Modify params](%s_params_modify.md) | [Output params](%s_outputs.md) | [Operations](%s_ops.md) | [Example](%s_example.md)", base, base, base, base, base, base)
|
||||
|
||||
writeFile(filepath.Join(docsDir, base+".md"), buildManualPage(spec, nav))
|
||||
writeFile(filepath.Join(docsDir, base+"_example.md"), buildExamplePage(spec, nav, version))
|
||||
writeFile(filepath.Join(docsDir, base+"_example.md"), buildExamplePage(spec, nav, version, apiEndpoint))
|
||||
writeFile(filepath.Join(docsDir, base+"_params_create.md"), buildCreateParamsPage(spec, nav))
|
||||
writeFile(filepath.Join(docsDir, base+"_params_modify.md"), buildModifyParamsPage(spec, nav))
|
||||
writeFile(filepath.Join(docsDir, base+"_outputs.md"), buildOutputsPage(spec, nav))
|
||||
@@ -263,12 +265,12 @@ func buildManualPage(spec ServiceSpec, nav string) string {
|
||||
return b.String()
|
||||
}
|
||||
|
||||
func buildExamplePage(spec ServiceSpec, nav, version string) string {
|
||||
func buildExamplePage(spec ServiceSpec, nav, version string, apiEndpoint string) string {
|
||||
var b strings.Builder
|
||||
b.WriteString(buildHeader(spec, nav))
|
||||
b.WriteString(fmt.Sprintf("## Copy-ready manifest (`%s_main.tf`)\n\n", spec.Name))
|
||||
b.WriteString("<div class=\"copy-ready-code\"><pre><code>")
|
||||
b.WriteString(exampleBlock(spec, version))
|
||||
b.WriteString(exampleBlock(spec, version, apiEndpoint))
|
||||
b.WriteString("</code></pre></div>\n\n")
|
||||
b.WriteString("## Outputs usage\n\n")
|
||||
b.WriteString("<div class=\"copy-ready-code\"><pre><code>")
|
||||
@@ -285,7 +287,7 @@ func buildExamplePage(spec ServiceSpec, nav, version string) string {
|
||||
return b.String()
|
||||
}
|
||||
|
||||
func exampleBlock(spec ServiceSpec, version string) string {
|
||||
func exampleBlock(spec ServiceSpec, version string, apiEndpoint string) string {
|
||||
createParams := findParams(spec.Operations, "create")
|
||||
requiredParams, defaultParams := splitParams(createParams)
|
||||
|
||||
@@ -301,7 +303,7 @@ func exampleBlock(spec ServiceSpec, version string) string {
|
||||
b.WriteString("# Токен доступа api_token к Nubes API — замените на реальный.\n")
|
||||
b.WriteString("provider \"nubes\" {\n")
|
||||
b.WriteString(" api_token = \"token_***\"\n")
|
||||
b.WriteString(" api_endpoint = \"https://deck-api.ngcloud.ru/api/v1/index.cfm\"\n")
|
||||
b.WriteString(fmt.Sprintf(" api_endpoint = \"%s\"\n", apiEndpoint))
|
||||
b.WriteString("}\n")
|
||||
b.WriteString(fmt.Sprintf("resource \"nubes_%s\" \"baza\" {\n", spec.Name))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user