609c9dab02
Ensure we close the Sentinel Evaluator so as not to leak go routines Fix a bunch of test logging so that various warnings when starting a test agent go to the ltest logger and not straight to stdout. Various canned ent meta types always return a valid pointer (no more nils). This allows us to blindly deref + assign in various places. Update ACL index tracking to ensure oss -> ent upgrades will work as expected. Update ent meta parsing to include function to disallow wildcarding.
45 lines
1.1 KiB
Go
45 lines
1.1 KiB
Go
// +build !consulent
|
|
|
|
package agent
|
|
|
|
import (
|
|
"fmt"
|
|
"net/http"
|
|
"strings"
|
|
|
|
"github.com/hashicorp/consul/agent/structs"
|
|
)
|
|
|
|
func (s *HTTPServer) parseEntMeta(req *http.Request, entMeta *structs.EnterpriseMeta) error {
|
|
if headerNS := req.Header.Get("X-Consul-Namespace"); headerNS != "" {
|
|
return BadRequestError{Reason: "Invalid header: \"X-Consul-Namespace\" - Namespaces is a Consul Enterprise feature"}
|
|
}
|
|
if queryNS := req.URL.Query().Get("ns"); queryNS != "" {
|
|
return BadRequestError{Reason: "Invalid query parameter: \"ns\" - Namespaces is a Consul Enterprise feature"}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (s *HTTPServer) parseEntMetaNoWildcard(req *http.Request, _ *structs.EnterpriseMeta) error {
|
|
return s.parseEntMeta(req, nil)
|
|
}
|
|
|
|
func (s *HTTPServer) rewordUnknownEnterpriseFieldError(err error) error {
|
|
if err == nil {
|
|
return nil
|
|
}
|
|
|
|
msg := err.Error()
|
|
|
|
if strings.Contains(msg, "json: unknown field ") {
|
|
quotedField := strings.TrimPrefix(msg, "json: unknown field ")
|
|
|
|
switch quotedField {
|
|
case `"Namespace"`:
|
|
return fmt.Errorf("%v - Namespaces is a Consul Enterprise feature", err)
|
|
}
|
|
}
|
|
|
|
return err
|
|
}
|