mirror of https://github.com/hashicorp/consul
consul: rename function to avoid collision and clean up
parent
6623538c93
commit
d217c25668
|
@ -309,10 +309,10 @@ func (f *aclFilter) filterNodeDump(dump *structs.NodeDump) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// aclFilter is used to filter results from our service catalog based on the
|
// filterACL is used to filter results from our service catalog based on the
|
||||||
// rules configured for the provided token. The subject is scrubbed and
|
// rules configured for the provided token. The subject is scrubbed and
|
||||||
// modified in-place, leaving only resources the token can access.
|
// modified in-place, leaving only resources the token can access.
|
||||||
func (s *Server) aclFilter(token string, subj interface{}) error {
|
func (s *Server) filterACL(token string, subj interface{}) error {
|
||||||
// Get the ACL from the token
|
// Get the ACL from the token
|
||||||
acl, err := s.resolveToken(token)
|
acl, err := s.resolveToken(token)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -126,7 +126,7 @@ func (c *Catalog) ListNodes(args *structs.DCSpecificRequest, reply *structs.Inde
|
||||||
state.QueryTables("Nodes"),
|
state.QueryTables("Nodes"),
|
||||||
func() error {
|
func() error {
|
||||||
reply.Index, reply.Nodes = state.Nodes()
|
reply.Index, reply.Nodes = state.Nodes()
|
||||||
return c.srv.aclFilter(args.Token, reply)
|
return c.srv.filterACL(args.Token, reply)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,7 +143,7 @@ func (c *Catalog) ListServices(args *structs.DCSpecificRequest, reply *structs.I
|
||||||
state.QueryTables("Services"),
|
state.QueryTables("Services"),
|
||||||
func() error {
|
func() error {
|
||||||
reply.Index, reply.Services = state.Services()
|
reply.Index, reply.Services = state.Services()
|
||||||
return c.srv.aclFilter(args.Token, reply)
|
return c.srv.filterACL(args.Token, reply)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -169,7 +169,7 @@ func (c *Catalog) ServiceNodes(args *structs.ServiceSpecificRequest, reply *stru
|
||||||
} else {
|
} else {
|
||||||
reply.Index, reply.ServiceNodes = state.ServiceNodes(args.ServiceName)
|
reply.Index, reply.ServiceNodes = state.ServiceNodes(args.ServiceName)
|
||||||
}
|
}
|
||||||
return c.srv.aclFilter(args.Token, reply)
|
return c.srv.filterACL(args.Token, reply)
|
||||||
})
|
})
|
||||||
|
|
||||||
// Provide some metrics
|
// Provide some metrics
|
||||||
|
@ -203,6 +203,6 @@ func (c *Catalog) NodeServices(args *structs.NodeSpecificRequest, reply *structs
|
||||||
state.QueryTables("NodeServices"),
|
state.QueryTables("NodeServices"),
|
||||||
func() error {
|
func() error {
|
||||||
reply.Index, reply.NodeServices = state.NodeServices(args.Node)
|
reply.Index, reply.NodeServices = state.NodeServices(args.Node)
|
||||||
return c.srv.aclFilter(args.Token, reply)
|
return c.srv.filterACL(args.Token, reply)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -778,7 +778,7 @@ func TestCatalogRegister_FailedCase1(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCatalog_applyDiscoveryACLs(t *testing.T) {
|
func TestCatalog_filterACL(t *testing.T) {
|
||||||
dir, srv := testServerWithConfig(t, func(c *Config) {
|
dir, srv := testServerWithConfig(t, func(c *Config) {
|
||||||
c.ACLDatacenter = "dc1"
|
c.ACLDatacenter = "dc1"
|
||||||
c.ACLMasterToken = "root"
|
c.ACLMasterToken = "root"
|
||||||
|
|
|
@ -43,7 +43,7 @@ func (h *Health) NodeChecks(args *structs.NodeSpecificRequest,
|
||||||
state.QueryTables("NodeChecks"),
|
state.QueryTables("NodeChecks"),
|
||||||
func() error {
|
func() error {
|
||||||
reply.Index, reply.HealthChecks = state.NodeChecks(args.Node)
|
reply.Index, reply.HealthChecks = state.NodeChecks(args.Node)
|
||||||
return h.srv.aclFilter(args.Token, reply)
|
return h.srv.filterACL(args.Token, reply)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ func (h *Health) ServiceChecks(args *structs.ServiceSpecificRequest,
|
||||||
state.QueryTables("ServiceChecks"),
|
state.QueryTables("ServiceChecks"),
|
||||||
func() error {
|
func() error {
|
||||||
reply.Index, reply.HealthChecks = state.ServiceChecks(args.ServiceName)
|
reply.Index, reply.HealthChecks = state.ServiceChecks(args.ServiceName)
|
||||||
return h.srv.aclFilter(args.Token, reply)
|
return h.srv.filterACL(args.Token, reply)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ func (h *Health) ServiceNodes(args *structs.ServiceSpecificRequest, reply *struc
|
||||||
} else {
|
} else {
|
||||||
reply.Index, reply.Nodes = state.CheckServiceNodes(args.ServiceName)
|
reply.Index, reply.Nodes = state.CheckServiceNodes(args.ServiceName)
|
||||||
}
|
}
|
||||||
return h.srv.aclFilter(args.Token, reply)
|
return h.srv.filterACL(args.Token, reply)
|
||||||
})
|
})
|
||||||
|
|
||||||
// Provide some metrics
|
// Provide some metrics
|
||||||
|
|
|
@ -223,7 +223,7 @@ func TestHealth_ServiceNodes(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestHealth_applyDiscoveryACLs(t *testing.T) {
|
func TestHealth_filterACL(t *testing.T) {
|
||||||
dir, srv := testServerWithConfig(t, func(c *Config) {
|
dir, srv := testServerWithConfig(t, func(c *Config) {
|
||||||
c.ACLDatacenter = "dc1"
|
c.ACLDatacenter = "dc1"
|
||||||
c.ACLMasterToken = "root"
|
c.ACLMasterToken = "root"
|
||||||
|
|
|
@ -25,12 +25,8 @@ func (m *Internal) NodeInfo(args *structs.NodeSpecificRequest,
|
||||||
&reply.QueryMeta,
|
&reply.QueryMeta,
|
||||||
state.QueryTables("NodeInfo"),
|
state.QueryTables("NodeInfo"),
|
||||||
func() error {
|
func() error {
|
||||||
index, dump := state.NodeInfo(args.Node)
|
reply.Index, reply.Dump = state.NodeInfo(args.Node)
|
||||||
if err := m.srv.aclFilter(args.Token, &dump); err != nil {
|
return m.srv.filterACL(args.Token, reply)
|
||||||
return err
|
|
||||||
}
|
|
||||||
reply.Index, reply.Dump = index, dump
|
|
||||||
return nil
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,12 +43,8 @@ func (m *Internal) NodeDump(args *structs.DCSpecificRequest,
|
||||||
&reply.QueryMeta,
|
&reply.QueryMeta,
|
||||||
state.QueryTables("NodeDump"),
|
state.QueryTables("NodeDump"),
|
||||||
func() error {
|
func() error {
|
||||||
index, dump := state.NodeDump()
|
reply.Index, reply.Dump = state.NodeDump()
|
||||||
if err := m.srv.aclFilter(args.Token, &dump); err != nil {
|
return m.srv.filterACL(args.Token, reply)
|
||||||
return err
|
|
||||||
}
|
|
||||||
reply.Index, reply.Dump = index, dump
|
|
||||||
return nil
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue