Skip to content

Commit b35e0f9

Browse files
AlinsRanCopilot
andcommitted
fix: populate global_rules and plugin_metadata in ADC validate payload
buildAPISIXValidatePayload now includes GlobalRules (as a single GlobalRuleItem with generated ID) and PluginMetadata (per plugin name) in the validation request, ensuring APISIX validates the full config context rather than silently omitting these resources. Note: double ingress-class resolution in buildTask is retained to preserve the early-exit behavior (configs empty = no ADC server configured = skip validation). A proper single-resolution refactoring would require changes to PrepareApisixRouteForValidation signatures. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 4789243 commit b35e0f9

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

internal/adc/client/executor.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,27 @@ func buildAPISIXValidatePayload(resources *adctypes.Resources) (*apisixValidateR
403403
body.SSLs = append(body.SSLs, sslMap)
404404
}
405405

406+
if len(resources.GlobalRules) > 0 {
407+
globalRuleMap, err := toMap(&adctypes.GlobalRuleItem{
408+
Metadata: adctypes.Metadata{ID: "validation-global-rule"},
409+
Plugins: adctypes.Plugins(resources.GlobalRules),
410+
})
411+
if err != nil {
412+
return nil, err
413+
}
414+
body.GlobalRules = append(body.GlobalRules, globalRuleMap)
415+
}
416+
417+
for pluginName, pluginConfig := range resources.PluginMetadata {
418+
m := map[string]any{"id": pluginName}
419+
if cfg, ok := pluginConfig.(map[string]any); ok {
420+
for k, v := range cfg {
421+
m[k] = v
422+
}
423+
}
424+
body.PluginMetadata = append(body.PluginMetadata, m)
425+
}
426+
406427
return body, nil
407428
}
408429

0 commit comments

Comments
 (0)