31 lines
936 B
Go
31 lines
936 B
Go
package app
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"log/slog"
|
|
|
|
"gitea.maximumdirect.net/eric/narratio/internal/adapters/storage"
|
|
"gitea.maximumdirect.net/eric/narratio/internal/config"
|
|
)
|
|
|
|
func newCommandObjectStoreWithDependencies(ctx context.Context, cfg *config.Config, logger *slog.Logger, deps commandDependencies) (storage.ObjectStore, error) {
|
|
deps = normalizeCommandDependencies(deps)
|
|
if _, err := loadSecretsFromConfigWithDependencies(cfg, logger, deps); err != nil {
|
|
return nil, fmt.Errorf("load secrets from files: %w", err)
|
|
}
|
|
return initializeObjectStoreBackend(ctx, cfg, deps.newObjectStore)
|
|
}
|
|
|
|
func initializeObjectStoreBackend(
|
|
ctx context.Context,
|
|
cfg *config.Config,
|
|
factory func(context.Context, *config.Config) (storage.ObjectStore, error),
|
|
) (storage.ObjectStore, error) {
|
|
store, err := factory(ctx, cfg)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("initialize object store backend: %w", err)
|
|
}
|
|
return store, nil
|
|
}
|