List enumerates auth JSON files from the mirrored workspace.
(_ context.Context)
| 236 | |
| 237 | // List enumerates auth JSON files from the mirrored workspace. |
| 238 | func (s *ObjectTokenStore) List(_ context.Context) ([]*cliproxyauth.Auth, error) { |
| 239 | dir := strings.TrimSpace(s.AuthDir()) |
| 240 | if dir == "" { |
| 241 | return nil, fmt.Errorf("object store: auth directory not configured") |
| 242 | } |
| 243 | entries := make([]*cliproxyauth.Auth, 0, 32) |
| 244 | err := filepath.WalkDir(dir, func(path string, d fs.DirEntry, walkErr error) error { |
| 245 | if walkErr != nil { |
| 246 | return walkErr |
| 247 | } |
| 248 | if d.IsDir() { |
| 249 | return nil |
| 250 | } |
| 251 | if !strings.HasSuffix(strings.ToLower(d.Name()), ".json") { |
| 252 | return nil |
| 253 | } |
| 254 | auth, err := s.readAuthFile(path, dir) |
| 255 | if err != nil { |
| 256 | log.WithError(err).Warnf("object store: skip auth %s", path) |
| 257 | return nil |
| 258 | } |
| 259 | if auth != nil { |
| 260 | entries = append(entries, auth) |
| 261 | } |
| 262 | return nil |
| 263 | }) |
| 264 | if err != nil { |
| 265 | return nil, fmt.Errorf("object store: walk auth directory: %w", err) |
| 266 | } |
| 267 | return entries, nil |
| 268 | } |
| 269 | |
| 270 | // Delete removes an auth file locally and remotely. |
| 271 | func (s *ObjectTokenStore) Delete(ctx context.Context, id string) error { |
nothing calls this directly
no test coverage detected