mirror of
https://github.com/status-im/consul.git
synced 2025-02-02 08:56:43 +00:00
ca: Add CARoots.Active method
Which will be used in the next commit.
This commit is contained in:
parent
5f5720837b
commit
a5d9b1d322
@ -252,18 +252,8 @@ func caRootsTxn(tx ReadTxn, ws memdb.WatchSet) (uint64, structs.CARoots, error)
|
|||||||
func (s *Store) CARootActive(ws memdb.WatchSet) (uint64, *structs.CARoot, error) {
|
func (s *Store) CARootActive(ws memdb.WatchSet) (uint64, *structs.CARoot, error) {
|
||||||
// Get all the roots since there should never be that many and just
|
// Get all the roots since there should never be that many and just
|
||||||
// do the filtering in this method.
|
// do the filtering in this method.
|
||||||
var result *structs.CARoot
|
|
||||||
idx, roots, err := s.CARoots(ws)
|
idx, roots, err := s.CARoots(ws)
|
||||||
if err == nil {
|
return idx, roots.Active(), err
|
||||||
for _, r := range roots {
|
|
||||||
if r.Active {
|
|
||||||
result = r
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return idx, result, err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// CARootSetCAS sets the current CA root state using a check-and-set operation.
|
// CARootSetCAS sets the current CA root state using a check-and-set operation.
|
||||||
|
@ -145,6 +145,20 @@ func (c *CARoot) Clone() *CARoot {
|
|||||||
// CARoots is a list of CARoot structures.
|
// CARoots is a list of CARoot structures.
|
||||||
type CARoots []*CARoot
|
type CARoots []*CARoot
|
||||||
|
|
||||||
|
// Active returns the single CARoot that is marked as active, or nil if there
|
||||||
|
// is no active root (ex: when they are no roots).
|
||||||
|
func (c CARoots) Active() *CARoot {
|
||||||
|
if c == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
for _, r := range c {
|
||||||
|
if r.Active {
|
||||||
|
return r
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// CASignRequest is the request for signing a service certificate.
|
// CASignRequest is the request for signing a service certificate.
|
||||||
type CASignRequest struct {
|
type CASignRequest struct {
|
||||||
// Datacenter is the target for this request.
|
// Datacenter is the target for this request.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user