MigrateToKeyring migrates credentials from file to keyring.
()
| 207 | |
| 208 | // MigrateToKeyring migrates credentials from file to keyring. |
| 209 | func (s *Store) MigrateToKeyring() error { |
| 210 | s.ensureInit() |
| 211 | if !s.useKeyring { |
| 212 | return nil |
| 213 | } |
| 214 | |
| 215 | all, err := s.loadAllFromFile() |
| 216 | if err != nil { |
| 217 | return nil //nolint:nilerr // No file to migrate is not an error |
| 218 | } |
| 219 | |
| 220 | for origin, creds := range all { |
| 221 | if err := s.saveToKeyring(origin, creds); err != nil { |
| 222 | return fmt.Errorf("failed to migrate %s: %w", origin, err) |
| 223 | } |
| 224 | } |
| 225 | |
| 226 | _ = os.Remove(s.credentialsPath()) |
| 227 | return nil |
| 228 | } |
| 229 | |
| 230 | // UsingKeyring returns true if the store is using the system keyring. |
| 231 | func (s *Store) UsingKeyring() bool { |
nothing calls this directly
no test coverage detected