Refactor: config  endpoint block check should not depend on labels (required or/and not ...)
@@ -275,6 +275,15 @@ func refineEndpoints(definedBackends Backends, endpoints config.Endpoints) error
proxies := endpointContent.Blocks.OfType(proxy)
requests := endpointContent.Blocks.OfType(request)
+
+ if len(proxies)+len(requests) == 0 && endpoint.Response == nil {
+ return hcl.Diagnostics{&hcl.Diagnostic{
+ Severity: hcl.DiagError,
+ Summary: "missing 'default' proxy or request block, or a response definition",
+ Subject: &endpointContent.MissingItemRange,
+ }}
+ }
+
proxyRequestLabelRequired := len(proxies)+len(requests) > 1
for _, proxyBlock := range proxies {
@@ -368,14 +377,6 @@ func refineEndpoints(definedBackends Backends, endpoints config.Endpoints) error
}
}
}
-
- if len(unique) == 0 && endpoint.Response == nil {
- return hcl.Diagnostics{&hcl.Diagnostic{
- Severity: hcl.DiagError,
- Summary: "missing 'default' proxy or request block, or a response definition",
- Subject: &itemRange,
- }}
- }
}
return nil
