diff options
Diffstat (limited to 'pkg/config')
-rw-r--r-- | pkg/config/config.go | 64 | ||||
-rw-r--r-- | pkg/config/config_test.go | 9 |
2 files changed, 60 insertions, 13 deletions
diff --git a/pkg/config/config.go b/pkg/config/config.go index fd19808..812a06e 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -30,10 +30,13 @@ type ( // configuration represents file configuration. // fields needs to be exported to cmp to work configuration struct { - Scan *scan - RootReadme string - ListenAddr string - Repositories []*GitRepositoryConfiguration + Scan *scan + RootReadme string + ListenAddr string + Passphrase string + SyntaxHighlight string + AESKey string + Repositories []*GitRepositoryConfiguration } // This is a per repository configuration. @@ -50,9 +53,12 @@ type ( // This holds all the function necessary to ask for configuration // information. ConfigurationRepository struct { - rootReadme string - listenAddr string - repositories []*GitRepositoryConfiguration + rootReadme string + listenAddr string + passphrase string + aesKey string + syntaxHighlight string + repositories []*GitRepositoryConfiguration } ) @@ -68,9 +74,12 @@ func LoadConfigurationRepository(configPath string) (*ConfigurationRepository, e } repo := &ConfigurationRepository{ - rootReadme: config.RootReadme, - listenAddr: config.ListenAddr, - repositories: config.Repositories, + aesKey: config.AESKey, + listenAddr: config.ListenAddr, + passphrase: config.Passphrase, + repositories: config.Repositories, + rootReadme: config.RootReadme, + syntaxHighlight: config.SyntaxHighlight, } if config.Scan.Path != "" { @@ -81,7 +90,6 @@ func LoadConfigurationRepository(configPath string) (*ConfigurationRepository, e } return repo, nil - } // GetRootReadme returns root read path @@ -89,6 +97,10 @@ func (c *ConfigurationRepository) GetRootReadme() string { return c.rootReadme } +func (c *ConfigurationRepository) GetSyntaxHighlight() string { + return c.syntaxHighlight +} + func (c *ConfigurationRepository) GetListenAddr() string { return c.listenAddr } @@ -170,6 +182,21 @@ func parse(r io.Reader) (*configuration, error) { return nil, err } + err = setPassphrase(block, &config.Passphrase) + if err != nil { + return nil, err + } + + err = setAESKey(block, &config.AESKey) + if err != nil { + return nil, err + } + + err = setSyntaxHighlight(block, &config.SyntaxHighlight) + if err != nil { + return nil, err + } + err = setRepositories(block, &config.Repositories) if err != nil { return nil, err @@ -263,6 +290,21 @@ func setRootReadme(block scfg.Block, readme *string) error { return setString(scanDir, readme) } +func setPassphrase(block scfg.Block, listenAddr *string) error { + scanDir := block.Get("passphrase") + return setString(scanDir, listenAddr) +} + +func setAESKey(block scfg.Block, listenAddr *string) error { + scanDir := block.Get("aes-key") + return setString(scanDir, listenAddr) +} + +func setSyntaxHighlight(block scfg.Block, listenAddr *string) error { + scanDir := block.Get("syntax-highlight") + return setString(scanDir, listenAddr) +} + func setListenAddr(block scfg.Block, listenAddr *string) error { scanDir := block.Get("listen-addr") return setString(scanDir, listenAddr) diff --git a/pkg/config/config_test.go b/pkg/config/config_test.go index 8c1d27e..9080351 100644 --- a/pkg/config/config_test.go +++ b/pkg/config/config_test.go @@ -103,6 +103,9 @@ repository /srv/git/cerrado.git { name: "complete", config: ` listen-addr unix://var/run/cerrado/cerrado.sock +passphrase $2a$14$VnB/ZcB1DUDkMnosRA6Y7.dj8h5eroslDxTeXlLwfQX/x86mh6WAq +aes-key 8XHptZxSWCGs1m7QzztX5zNQ7D9NiQevVX0DaUTNMbDpRwFzoJiB0U7K6O/kqIt01jJVgzBUfiR8ES46ZLLb4w== +syntax-highlight monokailight scan "/srv/git" { public true @@ -121,7 +124,10 @@ repository /srv/git/cerrado.git { Public: true, Path: "/srv/git", }, - ListenAddr: "unix://var/run/cerrado/cerrado.sock", + ListenAddr: "unix://var/run/cerrado/cerrado.sock", + Passphrase: "$2a$14$VnB/ZcB1DUDkMnosRA6Y7.dj8h5eroslDxTeXlLwfQX/x86mh6WAq", + AESKey: "8XHptZxSWCGs1m7QzztX5zNQ7D9NiQevVX0DaUTNMbDpRwFzoJiB0U7K6O/kqIt01jJVgzBUfiR8ES46ZLLb4w==", + SyntaxHighlight: "monokailight", Repositories: []*GitRepositoryConfiguration{ { Name: "linux.git", @@ -154,6 +160,5 @@ repository /srv/git/cerrado.git { t.Errorf("Wrong result given - wanted + got\n %s", diff) } }) - } } |