MCPcopy Create free account
hub / github.com/chainreactors/EvilProxy / List

Method List

internal/store/gitstore.go:350–382  ·  view source on GitHub ↗

List enumerates all auth JSON files under the configured directory.

(_ context.Context)

Source from the content-addressed store, hash-verified

348
349// List enumerates all auth JSON files under the configured directory.
350func (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.
385func (s *GitTokenStore) Delete(_ context.Context, id string) error {

Callers

nothing calls this directly

Calls 4

EnsureRepositoryMethod · 0.95
baseDirSnapshotMethod · 0.95
readAuthFileMethod · 0.95
NameMethod · 0.65

Tested by

no test coverage detected