RemoveKeys removes the keys with the given comment from the agent.
(comment string, opts ...AgentOption)
| 199 | |
| 200 | // RemoveKeys removes the keys with the given comment from the agent. |
| 201 | func (a *Agent) RemoveKeys(comment string, opts ...AgentOption) (bool, error) { |
| 202 | o := newOptions(opts) |
| 203 | keys, err := a.List() |
| 204 | if err != nil { |
| 205 | return false, errors.Wrap(err, "error listing keys") |
| 206 | } |
| 207 | |
| 208 | var removed bool |
| 209 | for _, key := range keys { |
| 210 | if key.Comment == comment { |
| 211 | if o.filterBySignatureKey == nil || o.filterBySignatureKey(key) { |
| 212 | if err := a.Remove(key); err != nil { |
| 213 | return false, errors.Wrap(err, "error removing key") |
| 214 | } |
| 215 | removed = true |
| 216 | } |
| 217 | } |
| 218 | } |
| 219 | |
| 220 | return removed, nil |
| 221 | } |
| 222 | |
| 223 | // RemoveAllKeys removes from the agent all the keys matching the given options. |
| 224 | func (a *Agent) RemoveAllKeys(opts ...AgentOption) (bool, error) { |
no test coverage detected