List enumerates all auth JSON files under the configured directory.
(_ context.Context)
| 348 | |
| 349 | // List enumerates all auth JSON files under the configured directory. |
| 350 | func (s *GitTokenStore) List(_ context.Context) ([]*cliproxyauth.Auth, error) { |
| 351 | if err := s.EnsureRepository(); err != nil { |
| 352 | return nil, err |
| 353 | } |
| 354 | dir := s.baseDirSnapshot() |
| 355 | if dir == "" { |
| 356 | return nil, fmt.Errorf("auth filestore: directory not configured") |
| 357 | } |
| 358 | entries := make([]*cliproxyauth.Auth, 0) |
| 359 | err := filepath.WalkDir(dir, func(path string, d fs.DirEntry, walkErr error) error { |
| 360 | if walkErr != nil { |
| 361 | return walkErr |
| 362 | } |
| 363 | if d.IsDir() { |
| 364 | return nil |
| 365 | } |
| 366 | if !strings.HasSuffix(strings.ToLower(d.Name()), ".json") { |
| 367 | return nil |
| 368 | } |
| 369 | auth, err := s.readAuthFile(path, dir) |
| 370 | if err != nil { |
| 371 | return nil |
| 372 | } |
| 373 | if auth != nil { |
| 374 | entries = append(entries, auth) |
| 375 | } |
| 376 | return nil |
| 377 | }) |
| 378 | if err != nil { |
| 379 | return nil, err |
| 380 | } |
| 381 | return entries, nil |
| 382 | } |
| 383 | |
| 384 | // Delete removes the auth file. |
| 385 | func (s *GitTokenStore) Delete(_ context.Context, id string) error { |
nothing calls this directly
no test coverage detected