package storage import ( "novamd/internal/git" ) // Manager interface combines all storage interfaces. type Manager interface { FileManager WorkspaceManager RepositoryManager } // Service represents the file system structure. type Service struct { fs fileSystem newGitClient func(url, user, token, path, commitName, commitEmail string) git.Client RootDir string GitRepos map[int]map[int]git.Client // map[userID]map[workspaceID]*git.Client } // Options represents the options for the storage service. type Options struct { Fs fileSystem NewGitClient func(url, user, token, path, commitName, commitEmail string) git.Client } // NewService creates a new Storage instance with the default options and the given rootDir root directory. func NewService(rootDir string) *Service { getLogger().Debug("creating new storage service", "rootDir", rootDir, "options", "default") return NewServiceWithOptions(rootDir, Options{ Fs: &osFS{}, NewGitClient: git.New, }) } // NewServiceWithOptions creates a new Storage instance with the given options and the given rootDir root directory. func NewServiceWithOptions(rootDir string, options Options) *Service { log := getLogger() log.Debug("creating new storage service with custom options", "rootDir", rootDir) if options.Fs == nil { log.Debug("filesystem not provided, using default osFS") options.Fs = &osFS{} } if options.NewGitClient == nil { log.Debug("git client factory not provided, using default git.New") options.NewGitClient = git.New } log.Info("storage service created", "rootDir", rootDir) return &Service{ fs: options.Fs, newGitClient: options.NewGitClient, RootDir: rootDir, GitRepos: make(map[int]map[int]git.Client), } }