|
|
|
@ -29,7 +29,8 @@ func init() {
|
|
|
|
|
registerCommand(structs.ACLPolicySetRequestType, (*FSM).applyACLPolicySetOperation)
|
|
|
|
|
registerCommand(structs.ACLPolicyDeleteRequestType, (*FSM).applyACLPolicyDeleteOperation)
|
|
|
|
|
registerCommand(structs.ConnectCALeafRequestType, (*FSM).applyConnectCALeafOperation)
|
|
|
|
|
registerCommand(structs.ConfigEntryRequestType, (*FSM).applyConfigEntryOperation)
|
|
|
|
|
registerCommand(structs.ServiceConfigEntryRequestType, (*FSM).applyServiceConfigEntryOperation)
|
|
|
|
|
registerCommand(structs.ProxyConfigEntryRequestType, (*FSM).applyProxyConfigEntryOperation)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (c *FSM) applyRegister(buf []byte, index uint64) interface{} {
|
|
|
|
@ -430,18 +431,37 @@ func (c *FSM) applyACLPolicyDeleteOperation(buf []byte, index uint64) interface{
|
|
|
|
|
return c.state.ACLPolicyBatchDelete(index, req.PolicyIDs)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (c *FSM) applyConfigEntryOperation(buf []byte, index uint64) interface{} {
|
|
|
|
|
var req structs.ConfigEntryRequest
|
|
|
|
|
func (c *FSM) applyServiceConfigEntryOperation(buf []byte, index uint64) interface{} {
|
|
|
|
|
req := structs.ConfigEntryRequest{
|
|
|
|
|
Entry: &structs.ServiceConfigEntry{},
|
|
|
|
|
}
|
|
|
|
|
if err := structs.Decode(buf, &req); err != nil {
|
|
|
|
|
panic(fmt.Errorf("failed to decode request: %v", err))
|
|
|
|
|
}
|
|
|
|
|
return c.applyConfigEntryOperation(index, req)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (c *FSM) applyProxyConfigEntryOperation(buf []byte, index uint64) interface{} {
|
|
|
|
|
req := structs.ConfigEntryRequest{
|
|
|
|
|
Entry: &structs.ProxyConfigEntry{},
|
|
|
|
|
}
|
|
|
|
|
if err := structs.Decode(buf, &req); err != nil {
|
|
|
|
|
panic(fmt.Errorf("failed to decode request: %v", err))
|
|
|
|
|
}
|
|
|
|
|
if err := c.applyConfigEntryOperation(index, req); err != nil {
|
|
|
|
|
panic(err)
|
|
|
|
|
}
|
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (c *FSM) applyConfigEntryOperation(index uint64, req structs.ConfigEntryRequest) error {
|
|
|
|
|
switch req.Op {
|
|
|
|
|
case structs.ConfigEntryUpsert:
|
|
|
|
|
defer metrics.MeasureSinceWithLabels([]string{"fsm", "config_entry"}, time.Now(),
|
|
|
|
|
defer metrics.MeasureSinceWithLabels([]string{"fsm", "config_entry", req.Entry.GetKind()}, time.Now(),
|
|
|
|
|
[]metrics.Label{{Name: "op", Value: "upsert"}})
|
|
|
|
|
return c.state.EnsureConfigEntry(index, req.Entry)
|
|
|
|
|
case structs.ConfigEntryDelete:
|
|
|
|
|
defer metrics.MeasureSinceWithLabels([]string{"fsm", "config_entry"}, time.Now(),
|
|
|
|
|
defer metrics.MeasureSinceWithLabels([]string{"fsm", "config_entry", req.Entry.GetKind()}, time.Now(),
|
|
|
|
|
[]metrics.Label{{Name: "op", Value: "delete"}})
|
|
|
|
|
return c.state.DeleteConfigEntry(req.Entry.GetKind(), req.Entry.GetName())
|
|
|
|
|
default:
|
|
|
|
|