Browse Source

ca: remove raftApply from delegate interface

After moving ca.ConsulProviderStateDelegate into the interface we now
have the ApplyCARequest method which does the same thing. Use this more
specific method instead of raftApply.
pull/10445/head
Daniel Nephin 3 years ago committed by Dhia Ayachi
parent
commit
1960c717af
  1. 13
      agent/consul/leader_connect_ca.go

13
agent/consul/leader_connect_ca.go

@ -37,7 +37,6 @@ type caServerDelegate interface {
forwardDC(method, dc string, args interface{}, reply interface{}) error forwardDC(method, dc string, args interface{}, reply interface{}) error
generateCASignRequest(csr string) *structs.CASignRequest generateCASignRequest(csr string) *structs.CASignRequest
raftApply(t structs.MessageType, msg interface{}) (interface{}, error)
checkServersProvider checkServersProvider
} }
@ -188,7 +187,7 @@ func (c *CAManager) initializeCAConfig() (*structs.CAConfiguration, error) {
Op: structs.CAOpSetConfig, Op: structs.CAOpSetConfig,
Config: config, Config: config,
} }
if resp, err := c.delegate.raftApply(structs.ConnectCARequestType, req); err != nil { if resp, err := c.delegate.ApplyCARequest(&req); err != nil {
return nil, err return nil, err
} else if respErr, ok := resp.(error); ok { } else if respErr, ok := resp.(error); ok {
return nil, respErr return nil, respErr
@ -475,7 +474,7 @@ func (c *CAManager) initializeRootCA(provider ca.Provider, conf *structs.CAConfi
Op: structs.CAOpSetConfig, Op: structs.CAOpSetConfig,
Config: conf, Config: conf,
} }
if _, err = c.delegate.raftApply(structs.ConnectCARequestType, req); err != nil { if _, err = c.delegate.ApplyCARequest(&req); err != nil {
return fmt.Errorf("error persisting provider state: %v", err) return fmt.Errorf("error persisting provider state: %v", err)
} }
} }
@ -524,7 +523,7 @@ func (c *CAManager) initializeRootCA(provider ca.Provider, conf *structs.CAConfi
} }
// Store the root cert in raft // Store the root cert in raft
resp, err := c.delegate.raftApply(structs.ConnectCARequestType, &structs.CARequest{ resp, err := c.delegate.ApplyCARequest(&structs.CARequest{
Op: structs.CAOpSetRoots, Op: structs.CAOpSetRoots,
Index: idx, Index: idx,
Roots: []*structs.CARoot{rootCA}, Roots: []*structs.CARoot{rootCA},
@ -732,7 +731,7 @@ func (c *CAManager) persistNewRootAndConfig(provider ca.Provider, newActiveRoot
Roots: newRoots, Roots: newRoots,
Config: &newConf, Config: &newConf,
} }
resp, err := c.delegate.raftApply(structs.ConnectCARequestType, args) resp, err := c.delegate.ApplyCARequest(args)
if err != nil { if err != nil {
return err return err
} }
@ -873,7 +872,7 @@ func (c *CAManager) UpdateConfiguration(args *structs.CARequest) (reterr error)
// If the root didn't change, just update the config and return. // If the root didn't change, just update the config and return.
if root != nil && root.ID == newActiveRoot.ID { if root != nil && root.ID == newActiveRoot.ID {
args.Op = structs.CAOpSetConfig args.Op = structs.CAOpSetConfig
resp, err := c.delegate.raftApply(structs.ConnectCARequestType, args) resp, err := c.delegate.ApplyCARequest(args)
if err != nil { if err != nil {
return err return err
} }
@ -976,7 +975,7 @@ func (c *CAManager) UpdateConfiguration(args *structs.CARequest) (reterr error)
args.Index = idx args.Index = idx
args.Config.ModifyIndex = confIdx args.Config.ModifyIndex = confIdx
args.Roots = newRoots args.Roots = newRoots
resp, err := c.delegate.raftApply(structs.ConnectCARequestType, args) resp, err := c.delegate.ApplyCARequest(args)
if err != nil { if err != nil {
return err return err
} }

Loading…
Cancel
Save