diff options
Diffstat (limited to 'pkg/config/config.go')
-rw-r--r-- | pkg/config/config.go | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/pkg/config/config.go b/pkg/config/config.go index 9dbf449..c00586b 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -51,6 +51,7 @@ type ( RootReadme string Scans []*scan SyntaxHighlight string + Hostname string } // This is a per repository configuration. @@ -75,6 +76,7 @@ type ( repositories []*GitRepositoryConfiguration rootReadme string syntaxHighlight string + hostname string } ) @@ -95,6 +97,7 @@ func LoadConfigurationRepository(configPath string) (*ConfigurationRepository, e passphrase: []byte(config.Passphrase), repositories: config.Repositories, rootReadme: config.RootReadme, + hostname: config.Hostname, syntaxHighlight: config.SyntaxHighlight, removeSuffix: config.RemoveSuffix, orderBy: parseOrderBy(config.OrderBy), @@ -117,6 +120,10 @@ func (c *ConfigurationRepository) GetRootReadme() string { return c.rootReadme } +func (c *ConfigurationRepository) GetHostname() string { + return c.hostname +} + func (c *ConfigurationRepository) GetOrderBy() OrderBy { return c.orderBy } @@ -219,6 +226,11 @@ func parse(r io.Reader) (*configuration, error) { return nil, err } + err = setHostname(block, &config.Hostname) + if err != nil { + return nil, err + } + err = setListenAddr(block, &config.ListenAddr) if err != nil { return nil, err @@ -311,11 +323,16 @@ func defaultConfiguration() *configuration { return &configuration{ Scans: defaultScans(), RootReadme: "", + Hostname: defaultHostname(), ListenAddr: defaultAddr(), Repositories: make([]*GitRepositoryConfiguration, 0), } } +func defaultHostname() string { + return "https://localhost:8080" +} + func defaultScans() []*scan { return []*scan{} } @@ -339,6 +356,11 @@ func setRootReadme(block scfg.Block, readme *string) error { return setString(scanDir, readme) } +func setHostname(block scfg.Block, hostname *string) error { + scanDir := block.Get("hostname") + return setString(scanDir, hostname) +} + func setPassphrase(block scfg.Block, listenAddr *string) error { scanDir := block.Get("passphrase") return setString(scanDir, listenAddr) |