try to infer command partition from node partition (#10981)

pull/10984/head
Dhia Ayachi 3 years ago committed by GitHub
parent a2e6a15e93
commit ced8329d80
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -235,7 +235,7 @@ func (s *HTTPHandlers) CatalogNodes(resp http.ResponseWriter, req *http.Request)
// Setup the request
args := structs.DCSpecificRequest{}
s.parseSource(req, &args.Source)
if err := parseEntMetaPartition(req, &args.EnterpriseMeta); err != nil {
if err := s.parseEntMetaPartition(req, &args.EnterpriseMeta); err != nil {
return nil, err
}
args.NodeMetaFilters = s.parseMetaFilter(req)

@ -82,7 +82,7 @@ func (s *HTTPHandlers) CoordinateNodes(resp http.ResponseWriter, req *http.Reque
if done := s.parse(resp, req, &args.Datacenter, &args.QueryOptions); done {
return nil, nil
}
if err := parseEntMetaPartition(req, &args.EnterpriseMeta); err != nil {
if err := s.parseEntMetaPartition(req, &args.EnterpriseMeta); err != nil {
return nil, err
}
@ -108,7 +108,7 @@ func (s *HTTPHandlers) CoordinateNode(resp http.ResponseWriter, req *http.Reques
if done := s.parse(resp, req, &args.Datacenter, &args.QueryOptions); done {
return nil, nil
}
if err := parseEntMetaPartition(req, &args.EnterpriseMeta); err != nil {
if err := s.parseEntMetaPartition(req, &args.EnterpriseMeta); err != nil {
return nil, err
}

@ -18,7 +18,7 @@ func (s *HTTPHandlers) parseEntMeta(req *http.Request, entMeta *structs.Enterpri
return BadRequestError{Reason: "Invalid query parameter: \"ns\" - Namespaces are a Consul Enterprise feature"}
}
return parseEntMetaPartition(req, entMeta)
return s.parseEntMetaPartition(req, entMeta)
}
func (s *HTTPHandlers) validateEnterpriseIntentionNamespace(logName, ns string, _ bool) error {
@ -75,7 +75,7 @@ func (s *HTTPHandlers) uiTemplateDataTransform(data map[string]interface{}) erro
return nil
}
func parseEntMetaPartition(req *http.Request, meta *structs.EnterpriseMeta) error {
func (s *HTTPHandlers) parseEntMetaPartition(req *http.Request, meta *structs.EnterpriseMeta) error {
if headerAP := req.Header.Get("X-Consul-Partition"); headerAP != "" {
return BadRequestError{Reason: "Invalid header: \"X-Consul-Partition\" - Partitions are a Consul Enterprise feature"}
}

@ -618,7 +618,7 @@ func (s *HTTPHandlers) UIMetricsProxy(resp http.ResponseWriter, req *http.Reques
s.clearTokenFromHeaders(req)
var entMeta structs.EnterpriseMeta
if err := parseEntMetaPartition(req, &entMeta); err != nil {
if err := s.parseEntMetaPartition(req, &entMeta); err != nil {
return nil, err
}
authz, err := s.agent.delegate.ResolveTokenAndDefaultMeta(token, &entMeta, nil)

Loading…
Cancel
Save