(act func(ctx context.Context, rep repo.DirectRepository) error)
| 410 | } |
| 411 | |
| 412 | func assertDirectRepository(act func(ctx context.Context, rep repo.DirectRepository) error) func(ctx context.Context, rep repo.Repository) error { |
| 413 | return func(ctx context.Context, rep repo.Repository) error { |
| 414 | if rep == nil { |
| 415 | return act(ctx, nil) |
| 416 | } |
| 417 | |
| 418 | // right now this assertion never fails, |
| 419 | // but will fail in the future when we have remote repository implementation |
| 420 | lr, ok := rep.(repo.DirectRepository) |
| 421 | if !ok { |
| 422 | return errors.New("operation supported only on direct repository") |
| 423 | } |
| 424 | |
| 425 | return act(ctx, lr) |
| 426 | } |
| 427 | } |
| 428 | |
| 429 | func (c *App) directRepositoryWriteAction(act func(ctx context.Context, rep repo.DirectRepositoryWriter) error) func(ctx *kingpin.ParseContext) error { |
| 430 | return c.repositoryAction(assertDirectRepository(func(ctx context.Context, rep repo.DirectRepository) error { |
no outgoing calls
no test coverage detected