github.com/DerekStrickland/consul@v1.4.5/agent/consul/consul_ca_delegate.go (about)

     1  package consul
     2  
     3  import (
     4  	"github.com/hashicorp/consul/agent/consul/state"
     5  	"github.com/hashicorp/consul/agent/structs"
     6  )
     7  
     8  // consulCADelegate providers callbacks for the Consul CA provider
     9  // to use the state store for its operations.
    10  type consulCADelegate struct {
    11  	srv *Server
    12  }
    13  
    14  func (c *consulCADelegate) State() *state.Store {
    15  	return c.srv.fsm.State()
    16  }
    17  
    18  func (c *consulCADelegate) ApplyCARequest(req *structs.CARequest) error {
    19  	resp, err := c.srv.raftApply(structs.ConnectCARequestType, req)
    20  	if err != nil {
    21  		return err
    22  	}
    23  	if respErr, ok := resp.(error); ok {
    24  		return respErr
    25  	}
    26  
    27  	return nil
    28  }