this repo has no description
1package processor
2
3import (
4 "fmt"
5 // "os"
6 // "path/filepath"
7 // "strings"
8
9 "github.com/aottr/nox/internal/config"
10 "github.com/aottr/nox/internal/gitrepo"
11)
12
13func ValidateConfig(cfg *config.Config) error {
14 if cfg.Age.Identity == "" {
15 return fmt.Errorf("age key path is required")
16 }
17
18 if cfg.StatePath == "" {
19 fmt.Printf("state path is not set, defaulting to default.\n")
20 }
21
22 for appName, app := range cfg.Apps {
23 fmt.Printf("✅ Validating app %s\n", appName)
24
25 repoURL := app.Repo
26 if repoURL == "" {
27 repoURL = cfg.DefaultRepo
28 }
29
30 repo, err := gitrepo.CloneRepoInMemory(gitrepo.GitFetchOptions{
31 RepoURL: repoURL,
32 Branch: app.Branch,
33 })
34 if err != nil {
35 return fmt.Errorf("failed to clone for app %s: %w", appName, err)
36 }
37
38 for _, file := range app.Files {
39 if !gitrepo.FileExistsInTree(repo.Tree, file.Path) {
40 return fmt.Errorf("❌ file %s missing in app %s", file, appName)
41 }
42 fmt.Printf("✔️ Found file %s in repo\n", file)
43 }
44 }
45 fmt.Println("✨ All checks passed!")
46 return nil
47}