List load all existing credentials
(repo repository.RepoKeyring, opts ...ListOption)
| 145 | |
| 146 | // List load all existing credentials |
| 147 | func List(repo repository.RepoKeyring, opts ...ListOption) ([]Credential, error) { |
| 148 | keys, err := repo.Keyring().Keys() |
| 149 | if err != nil { |
| 150 | return nil, err |
| 151 | } |
| 152 | |
| 153 | matcher := matcher(opts) |
| 154 | |
| 155 | var credentials []Credential |
| 156 | for _, key := range keys { |
| 157 | if !strings.HasPrefix(key, keyringKeyPrefix) { |
| 158 | continue |
| 159 | } |
| 160 | |
| 161 | item, err := repo.Keyring().Get(key) |
| 162 | if err != nil { |
| 163 | // skip unreadable items, nothing much we can do for them anyway |
| 164 | continue |
| 165 | } |
| 166 | |
| 167 | cred, err := decode(item) |
| 168 | if err != nil { |
| 169 | return nil, err |
| 170 | } |
| 171 | if matcher.Match(cred) { |
| 172 | credentials = append(credentials, cred) |
| 173 | } |
| 174 | } |
| 175 | |
| 176 | return credentials, nil |
| 177 | } |
| 178 | |
| 179 | // IdExist return whether a credential id exist or not |
| 180 | func IdExist(repo repository.RepoKeyring, id entity.Id) bool { |