aboutsummaryrefslogtreecommitdiff
path: root/pkg/config/config.go
diff options
context:
space:
mode:
authorGabriel A. Giovanini <mail@gabrielgio.me>2025-06-05 20:46:46 +0200
committerGabriel A. Giovanini <mail@gabrielgio.me>2025-06-05 20:49:54 +0200
commitcb6060a60d71ce1be1591bb10f499916155160de (patch)
tree0eaa303fe142a61c0ee7cc3518a5b4d150cf7789 /pkg/config/config.go
parent3739c9e14b0c65a59a520dbfefa459e43af3bf20 (diff)
downloadcerrado-cb6060a60d71ce1be1591bb10f499916155160de.tar.gz
cerrado-cb6060a60d71ce1be1591bb10f499916155160de.tar.bz2
cerrado-cb6060a60d71ce1be1591bb10f499916155160de.zip
feat: Add hostname configHEADmaster
Diffstat (limited to 'pkg/config/config.go')
-rw-r--r--pkg/config/config.go22
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)