package app import ( "context" "os" "gitea.maximumdirect.net/eric/narratio/internal/adapters/storage" "gitea.maximumdirect.net/eric/narratio/internal/config" ) type commandDependencies struct { loadPipelineConfig func(string, config.PipelineLoadOptions) (*config.PipelineConfig, error) downloadObjectToTemp func(context.Context, storage.ObjectStore, string, string) (string, error) readSecretsDirectory func(string) ([]os.DirEntry, error) newObjectStore func(context.Context, *config.Config) (storage.ObjectStore, error) discoverRemoteCurrentState func(context.Context, *config.Config, storage.ObjectStore) (*RemoteCurrentState, error) buildRestorePlan func(context.Context, *config.Config, *RemoteCurrentState, storage.ObjectStore, RestorePlanOptions) (*RestorePlan, error) executeRestorePlan func(context.Context, *config.Config, *RemoteCurrentState, *RestorePlan, *RestoreReport, storage.ObjectStore) (*RestoreExecutionResult, error) } func normalizeCommandDependencies(deps commandDependencies) commandDependencies { if deps.loadPipelineConfig == nil { deps.loadPipelineConfig = config.LoadPipelineWithOptions } if deps.downloadObjectToTemp == nil { deps.downloadObjectToTemp = storage.DownloadObjectToTemp } if deps.readSecretsDirectory == nil { deps.readSecretsDirectory = os.ReadDir } if deps.newObjectStore == nil { deps.newObjectStore = storage.NewObjectStoreFromConfig } if deps.discoverRemoteCurrentState == nil { deps.discoverRemoteCurrentState = discoverRemoteCurrentState } if deps.buildRestorePlan == nil { deps.buildRestorePlan = buildRestorePlan } if deps.executeRestorePlan == nil { deps.executeRestorePlan = executeRestorePlan } return deps }