diff options
Diffstat (limited to 'internal/config/config.go')
-rw-r--r-- | internal/config/config.go | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/internal/config/config.go b/internal/config/config.go index df69bce..7ccad85 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -3,10 +3,12 @@ package config import ( "io/fs" "net/url" - "website/internal/log" + "path/filepath" + + "go.alanpearce.eu/x/log" "github.com/BurntSushi/toml" - "github.com/pkg/errors" + "gitlab.com/tozd/go/errors" ) type Taxonomy struct { @@ -16,7 +18,7 @@ type Taxonomy struct { type MenuItem struct { Name string - URL string `toml:"url"` + URL URL `toml:"url"` } type URL struct { @@ -38,6 +40,9 @@ type Config struct { Description string DomainStartDate string `toml:"domain_start_date"` OriginalDomain string `toml:"original_domain"` + GoatCounter URL `toml:"goatcounter"` + Domains []string + WildcardDomain string `toml:"wildcard_domain"` OIDCHost URL `toml:"oidc_host"` Taxonomies []Taxonomy CSP *CSP `toml:"content-security-policy"` @@ -47,10 +52,11 @@ type Config struct { Menus map[string][]MenuItem } -func GetConfig() (*Config, error) { +func GetConfig(dir string, log *log.Logger) (*Config, error) { config := Config{} - log.Debug("reading config.toml") - _, err := toml.DecodeFile("config.toml", &config) + filename := filepath.Join(dir, "config.toml") + log.Debug("reading config", "filename", filename) + _, err := toml.DecodeFile(filename, &config) if err != nil { switch t := err.(type) { case *fs.PathError: |