update config module
This commit is contained in:
		| @@ -67,7 +67,7 @@ type action struct { | ||||
| // If repos is set to nil, the repos in the ALR config will be used. | ||||
| func (rs *Repos) Pull(ctx context.Context, repos []types.Repo) error { | ||||
| 	if repos == nil { | ||||
| 		repos = rs.cfg.Repos(ctx) | ||||
| 		repos = rs.cfg.Repos() | ||||
| 	} | ||||
|  | ||||
| 	for _, repo := range repos { | ||||
| @@ -77,7 +77,7 @@ func (rs *Repos) Pull(ctx context.Context, repos []types.Repo) error { | ||||
| 		} | ||||
|  | ||||
| 		slog.Info(gotext.Get("Pulling repository"), "name", repo.Name) | ||||
| 		repoDir := filepath.Join(rs.cfg.GetPaths(ctx).RepoDir, repo.Name) | ||||
| 		repoDir := filepath.Join(rs.cfg.GetPaths().RepoDir, repo.Name) | ||||
|  | ||||
| 		var repoFS billy.Filesystem | ||||
| 		gitDir := filepath.Join(repoDir, ".git") | ||||
|   | ||||
| @@ -32,13 +32,13 @@ import ( | ||||
|  | ||||
| type TestALRConfig struct{} | ||||
|  | ||||
| func (c *TestALRConfig) GetPaths(ctx context.Context) *config.Paths { | ||||
| func (c *TestALRConfig) GetPaths() *config.Paths { | ||||
| 	return &config.Paths{ | ||||
| 		DBPath: ":memory:", | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func (c *TestALRConfig) Repos(ctx context.Context) []types.Repo { | ||||
| func (c *TestALRConfig) Repos() []types.Repo { | ||||
| 	return []types.Repo{ | ||||
| 		{ | ||||
| 			Name: "test", | ||||
|   | ||||
| @@ -44,7 +44,7 @@ type TestALRConfig struct { | ||||
| 	PkgsDir  string | ||||
| } | ||||
|  | ||||
| func (c *TestALRConfig) GetPaths(ctx context.Context) *config.Paths { | ||||
| func (c *TestALRConfig) GetPaths() *config.Paths { | ||||
| 	return &config.Paths{ | ||||
| 		DBPath:   ":memory:", | ||||
| 		CacheDir: c.CacheDir, | ||||
| @@ -53,7 +53,7 @@ func (c *TestALRConfig) GetPaths(ctx context.Context) *config.Paths { | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func (c *TestALRConfig) Repos(ctx context.Context) []types.Repo { | ||||
| func (c *TestALRConfig) Repos() []types.Repo { | ||||
| 	return []types.Repo{} | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -17,16 +17,14 @@ | ||||
| package repos | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
|  | ||||
| 	"gitea.plemya-x.ru/Plemya-x/ALR/internal/config" | ||||
| 	database "gitea.plemya-x.ru/Plemya-x/ALR/internal/db" | ||||
| 	"gitea.plemya-x.ru/Plemya-x/ALR/internal/types" | ||||
| ) | ||||
|  | ||||
| type Config interface { | ||||
| 	GetPaths(ctx context.Context) *config.Paths | ||||
| 	Repos(ctx context.Context) []types.Repo | ||||
| 	GetPaths() *config.Paths | ||||
| 	Repos() []types.Repo | ||||
| } | ||||
|  | ||||
| type Repos struct { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user