HasKeys returns if a key filtered with the given options exists.
(opts ...AgentOption)
| 105 | |
| 106 | // HasKeys returns if a key filtered with the given options exists. |
| 107 | func (a *Agent) HasKeys(opts ...AgentOption) (bool, error) { |
| 108 | o := newOptions(opts) |
| 109 | keys, err := a.List() |
| 110 | if err != nil { |
| 111 | return false, errors.Wrap(err, "error listing keys") |
| 112 | } |
| 113 | for _, key := range keys { |
| 114 | if o.removeExpiredKey != nil && o.removeExpiredKey(a, key) { |
| 115 | continue |
| 116 | } |
| 117 | if o.filterBySignatureKey == nil || o.filterBySignatureKey(key) { |
| 118 | return true, nil |
| 119 | } |
| 120 | } |
| 121 | return false, nil |
| 122 | } |
| 123 | |
| 124 | // ListKeys returns the list of keys in the agent. |
| 125 | func (a *Agent) ListKeys(opts ...AgentOption) ([]*agent.Key, error) { |
no test coverage detected