package storage import ( "context" "fmt" "strings" "gitea.maximumdirect.net/eric/narratio/internal/config" ) // NewObjectStoreFromConfig constructs a remote object store from resolved config. func NewObjectStoreFromConfig(ctx context.Context, cfg *config.Config) (ObjectStore, error) { if cfg == nil || cfg.Pipeline == nil { return nil, fmt.Errorf("pipeline config is required") } switch strings.ToLower(strings.TrimSpace(cfg.Pipeline.Storage.Backend)) { case config.StorageBackendS3: if cfg.Pipeline.Storage.S3 == nil { return nil, fmt.Errorf("pipeline.storage.s3 is required when pipeline.storage.backend is s3") } return NewS3BackendFromConfig(ctx, *cfg.Pipeline.Storage.S3) case "", config.StorageBackendLocal: return nil, fmt.Errorf("no remote object store backend is configured") default: return nil, fmt.Errorf("unsupported pipeline.storage.backend %q", cfg.Pipeline.Storage.Backend) } }