MCPcopy
hub / github.com/smallstep/cli / HasKeys

Method HasKeys

internal/sshutil/agent.go:107–122  ·  view source on GitHub ↗

HasKeys returns if a key filtered with the given options exists.

(opts ...AgentOption)

Source from the content-addressed store, hash-verified

105
106// HasKeys returns if a key filtered with the given options exists.
107func (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.
125func (a *Agent) ListKeys(opts ...AgentOption) ([]*agent.Key, error) {

Callers 1

doLoginIfNeededFunction · 0.80

Calls 1

newOptionsFunction · 0.85

Tested by

no test coverage detected