aboutsummaryrefslogtreecommitdiff
path: root/pkg/config/config.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/config/config.go')
-rw-r--r--pkg/config/config.go52
1 files changed, 30 insertions, 22 deletions
diff --git a/pkg/config/config.go b/pkg/config/config.go
index c17e6df..1ad5108 100644
--- a/pkg/config/config.go
+++ b/pkg/config/config.go
@@ -30,7 +30,7 @@ type (
// configuration represents file configuration.
// fields needs to be exported to cmp to work
configuration struct {
- Scan *scan
+ Scans []*scan
RootReadme string
ListenAddr string
Passphrase string
@@ -82,10 +82,12 @@ func LoadConfigurationRepository(configPath string) (*ConfigurationRepository, e
syntaxHighlight: config.SyntaxHighlight,
}
- if config.Scan.Path != "" {
- err = repo.expandOnScanPath(config.Scan.Path, config.Scan.Public)
- if err != nil {
- return nil, err
+ for _, scan := range config.Scans {
+ if scan.Path != "" {
+ err = repo.expandOnScanPath(scan.Path, scan.Public)
+ if err != nil {
+ return nil, err
+ }
}
}
@@ -179,7 +181,7 @@ func parse(r io.Reader) (*configuration, error) {
config := defaultConfiguration()
- err = setScan(block, config.Scan)
+ err = setScan(block, &config.Scans)
if err != nil {
return nil, err
}
@@ -269,18 +271,15 @@ func setRepositories(block scfg.Block, repositories *[]*GitRepositoryConfigurati
func defaultConfiguration() *configuration {
return &configuration{
- Scan: defaultScan(),
+ Scans: defaultScans(),
RootReadme: "",
ListenAddr: defaultAddr(),
Repositories: make([]*GitRepositoryConfiguration, 0),
}
}
-func defaultScan() *scan {
- return &scan{
- Public: false,
- Path: "",
- }
+func defaultScans() []*scan {
+ return []*scan{}
}
func defaultAddr() string {
@@ -322,18 +321,27 @@ func setListenAddr(block scfg.Block, listenAddr *string) error {
return setString(scanDir, listenAddr)
}
-func setScan(block scfg.Block, scan *scan) error {
- scanDir := block.Get("scan")
- if scanDir == nil {
- return nil
- }
- err := setString(scanDir, &scan.Path)
- if err != nil {
- return err
+func setScan(block scfg.Block, scans *[]*scan) error {
+ for _, scanDir := range block.GetAll("scan") {
+ s := &scan{}
+ if scanDir == nil {
+ return nil
+ }
+ err := setString(scanDir, &s.Path)
+ if err != nil {
+ return err
+ }
+
+ public := scanDir.Children.Get("public")
+ err = setBool(public, &s.Public)
+ if err != nil {
+ return err
+ }
+
+ *scans = append(*scans, s)
}
- public := scanDir.Children.Get("public")
- return setBool(public, &scan.Public)
+ return nil
}
func setBool(dir *scfg.Directive, field *bool) error {