aboutsummaryrefslogtreecommitdiff
path: root/internal/admin/model.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/admin/model.go')
-rw-r--r--internal/admin/model.go20
1 files changed, 9 insertions, 11 deletions
diff --git a/internal/admin/model.go b/internal/admin/model.go
index 079496e..a797bbd 100644
--- a/internal/admin/model.go
+++ b/internal/admin/model.go
@@ -99,6 +99,7 @@ type ServerRepos struct {
func loadConfigFromGit(baseDir, filePath string) ([]byte, error) {
mgmtPath := filepath.Join(baseDir, mgmtRepoName)
+ slog.Info("loading server config", "configPath", mgmtPath)
_, err := os.Stat(mgmtPath)
if errors.Is(err, os.ErrNotExist) {
return []byte(""), ErrMgmtRepoNotFound
@@ -115,15 +116,6 @@ func loadConfigFromGit(baseDir, filePath string) ([]byte, error) {
if err != nil {
return []byte(""), fmt.Errorf("couldn't clone mgmt repo %s %w", repoURI, err)
}
- files, err := fs.ReadDir("/")
- if err != nil {
- log.Fatal(err)
- }
- for _, file := range files {
- fmt.Println(file)
-
- }
-
file, err := fs.Open(filePath)
if err != nil {
return []byte(""), fmt.Errorf("couldn't open file in repo %w", err)
@@ -204,10 +196,15 @@ func (s *ServerRepos) ServerPolicies() [][]string {
// ConfigureRepos run reconciler for all repos
func (s *ServerRepos) ConfigureRepos() error {
+ slog.Info("configuring repos", "toBeConfigured", len(s.Repos))
+ var errs []error
for _, repo := range s.Repos {
- return repo.ReconcileRepo(s.basePath)
+ if err := repo.ReconcileRepo(s.basePath); err != nil {
+ slog.Error("error reconcile", "repo", repo.Name, "err", err)
+ errs = append(errs, err)
+ }
}
- return nil
+ return errors.Join(errs...)
}
func readOnlyPaths(role, repoName string) [][]string {
@@ -250,6 +247,7 @@ func (r *GitRepo) CasbinPolicies() [][]string {
func (r *GitRepo) ReconcileRepo(basePath string) error {
// if exist -> continue
repoBase := filepath.Join(basePath, fmt.Sprintf("%s.git", r.Name))
+ slog.Info("reconciling repo", "repoPath", repoBase)
_, err := os.Stat(repoBase)
if errors.Is(err, fs.ErrNotExist) {
// if no exist -> init bare