(ctx context.Context, path string)
| 447 | } |
| 448 | |
| 449 | func (s *ObjectTokenStore) uploadAuth(ctx context.Context, path string) error { |
| 450 | if path == "" { |
| 451 | return nil |
| 452 | } |
| 453 | rel, err := filepath.Rel(s.authDir, path) |
| 454 | if err != nil { |
| 455 | return fmt.Errorf("object store: resolve auth relative path: %w", err) |
| 456 | } |
| 457 | data, err := os.ReadFile(path) |
| 458 | if err != nil { |
| 459 | if errors.Is(err, fs.ErrNotExist) { |
| 460 | return s.deleteAuthObject(ctx, path) |
| 461 | } |
| 462 | return fmt.Errorf("object store: read auth file: %w", err) |
| 463 | } |
| 464 | if len(data) == 0 { |
| 465 | return s.deleteAuthObject(ctx, path) |
| 466 | } |
| 467 | key := objectStoreAuthPrefix + "/" + filepath.ToSlash(rel) |
| 468 | return s.putObject(ctx, key, data, "application/json") |
| 469 | } |
| 470 | |
| 471 | func (s *ObjectTokenStore) deleteAuthObject(ctx context.Context, path string) error { |
| 472 | if path == "" { |
no test coverage detected