(roots []string)
| 18 | } |
| 19 | |
| 20 | func LoadFileConfigs(roots []string) ([]Config, []error) { |
| 21 | var cfgs []Config |
| 22 | var errs []error |
| 23 | |
| 24 | for _, root := range roots { |
| 25 | root = strings.TrimSpace(root) |
| 26 | if root == "" { |
| 27 | continue |
| 28 | } |
| 29 | |
| 30 | dir := filepath.Join(root, "ss") |
| 31 | entries, err := os.ReadDir(dir) |
| 32 | if err != nil { |
| 33 | continue |
| 34 | } |
| 35 | |
| 36 | for _, entry := range entries { |
| 37 | if !entry.Type().IsRegular() { |
| 38 | continue |
| 39 | } |
| 40 | |
| 41 | ext := strings.ToLower(filepath.Ext(entry.Name())) |
| 42 | if ext != ".conf" && ext != ".yaml" && ext != ".yml" { |
| 43 | continue |
| 44 | } |
| 45 | |
| 46 | path := filepath.Join(dir, entry.Name()) |
| 47 | stem := strings.TrimSpace(strings.TrimSuffix(entry.Name(), filepath.Ext(entry.Name()))) |
| 48 | |
| 49 | jobs, jobErrs := loadFileConfigJobs(path) |
| 50 | errs = append(errs, jobErrs...) |
| 51 | if len(jobs) == 0 { |
| 52 | continue |
| 53 | } |
| 54 | |
| 55 | sourceType := fileConfigSourceType(path) |
| 56 | source := "file=" + path |
| 57 | for i, job := range jobs { |
| 58 | cfg := Config(job) |
| 59 | if strings.TrimSpace(cfg.Name()) == "" { |
| 60 | errs = append(errs, fmt.Errorf("secretstore file config '%s' job %d: store name is required", path, i+1)) |
| 61 | continue |
| 62 | } |
| 63 | if cfg.Kind() == "" { |
| 64 | cfg.SetKind(StoreKind(stem)) |
| 65 | } |
| 66 | cfg.SetSource(source) |
| 67 | cfg.SetSourceType(sourceType) |
| 68 | if err := validateFileConfig(cfg); err != nil { |
| 69 | errs = append(errs, fmt.Errorf("secretstore file config '%s' job %d: %w", path, i+1, err)) |
| 70 | continue |
| 71 | } |
| 72 | cfgs = append(cfgs, cfg) |
| 73 | } |
| 74 | } |
| 75 | } |
| 76 | |
| 77 | return cfgs, errs |
nothing calls this directly
no test coverage detected
searching dependent graphs…