this repo has no description
1package config 2 3import ( 4 "context" 5 6 "github.com/sethvargo/go-envconfig" 7) 8 9type Repo struct { 10 ScanPath string `env:"SCAN_PATH, default=/home/git"` 11 Readme []string `env:"README"` 12 MainBranch []string `env:"MAIN_BRANCH"` 13} 14 15type Server struct { 16 Host string `env:"HOST, default=0.0.0.0"` 17 Port int `env:"PORT, default=5555"` 18 Secret string `env:"SECRET, required"` 19 DBPath string `env:"DB_PATH, default=knotserver.db"` 20 // This disables signature verification so use with caution. 21 Dev bool `env:"DEV, default=false"` 22} 23 24type Config struct { 25 Repo Repo `env:",prefix=KNOT_REPO_"` 26 Server Server `env:",prefix=KNOT_SERVER_"` 27} 28 29func Load(ctx context.Context) (*Config, error) { 30 var cfg Config 31 err := envconfig.Process(ctx, &cfg) 32 if err != nil { 33 return nil, err 34 } 35 36 if cfg.Repo.Readme == nil { 37 cfg.Repo.Readme = []string{ 38 "README.md", "readme.md", 39 "README", 40 "readme", 41 "README.markdown", 42 "readme.markdown", 43 "README.txt", 44 "readme.txt", 45 "README.rst", 46 "readme.rst", 47 "README.org", 48 "readme.org", 49 "README.asciidoc", 50 "readme.asciidoc", 51 } 52 } 53 54 return &cfg, nil 55}