2018-05-03 19:50:45 +00:00
|
|
|
package consul
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/hashicorp/consul/agent/consul/state"
|
|
|
|
"github.com/hashicorp/consul/agent/structs"
|
|
|
|
)
|
|
|
|
|
|
|
|
// consulCADelegate providers callbacks for the Consul CA provider
|
|
|
|
// to use the state store for its operations.
|
|
|
|
type consulCADelegate struct {
|
|
|
|
srv *Server
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *consulCADelegate) State() *state.Store {
|
|
|
|
return c.srv.fsm.State()
|
|
|
|
}
|
|
|
|
|
2020-01-09 15:32:19 +00:00
|
|
|
func (c *consulCADelegate) ApplyCARequest(req *structs.CARequest) (interface{}, error) {
|
2018-05-03 19:50:45 +00:00
|
|
|
resp, err := c.srv.raftApply(structs.ConnectCARequestType, req)
|
|
|
|
if err != nil {
|
2020-01-09 15:32:19 +00:00
|
|
|
return nil, err
|
2018-05-03 19:50:45 +00:00
|
|
|
}
|
|
|
|
if respErr, ok := resp.(error); ok {
|
2020-01-09 15:32:19 +00:00
|
|
|
return nil, respErr
|
2018-05-03 19:50:45 +00:00
|
|
|
}
|
|
|
|
|
2020-01-09 15:32:19 +00:00
|
|
|
return resp, nil
|
2018-05-03 19:50:45 +00:00
|
|
|
}
|