all repos — legit @ f8829d9e14bb3c971eee363ece5d5adebe2f2f56

web frontend for git

config/config.go (view raw)

 1package config
 2
 3import (
 4	"fmt"
 5	"os"
 6
 7	"gopkg.in/yaml.v3"
 8)
 9
10type Config struct {
11	Repo struct {
12		ScanPath   string   `yaml:"scanPath"`
13		Readme     []string `yaml:"readme"`
14		MainBranch []string `yaml:"mainBranch"`
15	} `yaml:"repo"`
16	Template struct {
17		Dir string `yaml:"dir"`
18	} `yaml:"template"`
19	Meta struct {
20		Title       string `yaml:"title"`
21		Description string `yaml:"description"`
22	} `yaml:"meta"`
23	Server struct {
24		Host string `yaml:"host"`
25		Port int    `yaml:"port"`
26	} `yaml:"server"`
27}
28
29func Read(f string) (*Config, error) {
30	b, err := os.ReadFile(f)
31	if err != nil {
32		return nil, fmt.Errorf("reading config: %w", err)
33	}
34
35	c := Config{}
36	if err := yaml.Unmarshal(b, &c); err != nil {
37		return nil, fmt.Errorf("parsing config: %w", err)
38	}
39
40	return &c, nil
41}