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 AppViewEndpoint string `env:"APPVIEW_ENDPOINT, default=https://tangled.sh"`
28}
29
30func Load(ctx context.Context) (*Config, error) {
31 var cfg Config
32 err := envconfig.Process(ctx, &cfg)
33 if err != nil {
34 return nil, err
35 }
36
37 if cfg.Repo.Readme == nil {
38 cfg.Repo.Readme = []string{
39 "README.md", "readme.md",
40 "README",
41 "readme",
42 "README.markdown",
43 "readme.markdown",
44 "README.txt",
45 "readme.txt",
46 "README.rst",
47 "readme.rst",
48 "README.org",
49 "readme.org",
50 "README.asciidoc",
51 "readme.asciidoc",
52 }
53 }
54
55 return &cfg, nil
56}