config: add top-level YAML namespace 'clair'
This enables Clair to use YAML configuration files that contain more than just a Clair configuration. Fixes #95.
This commit is contained in:
parent
f6ba17dfc7
commit
4fc32d2271
@ -13,7 +13,7 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
# The values specified here are the default values that Clair uses if no configuration file is specified or if the keys are not defined.
|
# The values specified here are the default values that Clair uses if no configuration file is specified or if the keys are not defined.
|
||||||
---
|
clair:
|
||||||
database:
|
database:
|
||||||
# PostgreSQL Connection string
|
# PostgreSQL Connection string
|
||||||
# http://www.postgresql.org/docs/9.4/static/libpq-connect.html
|
# http://www.postgresql.org/docs/9.4/static/libpq-connect.html
|
||||||
@ -43,6 +43,7 @@ api:
|
|||||||
# If you want to easily generate client certificates and CAs, try the following projects:
|
# If you want to easily generate client certificates and CAs, try the following projects:
|
||||||
# https://github.com/coreos/etcd-ca
|
# https://github.com/coreos/etcd-ca
|
||||||
# https://github.com/cloudflare/cfssl
|
# https://github.com/cloudflare/cfssl
|
||||||
|
servername:
|
||||||
cafile:
|
cafile:
|
||||||
keyfile:
|
keyfile:
|
||||||
certfile:
|
certfile:
|
||||||
@ -65,8 +66,8 @@ notifier:
|
|||||||
|
|
||||||
# Optional PKI configuration
|
# Optional PKI configuration
|
||||||
# If you want to easily generate client certificates and CAs, try the following projects:
|
# If you want to easily generate client certificates and CAs, try the following projects:
|
||||||
# https://github.com/coreos/etcd-ca
|
|
||||||
# https://github.com/cloudflare/cfssl
|
# https://github.com/cloudflare/cfssl
|
||||||
|
# https://github.com/coreos/etcd-ca
|
||||||
servername:
|
servername:
|
||||||
cafile:
|
cafile:
|
||||||
keyfile:
|
keyfile:
|
||||||
|
@ -23,6 +23,12 @@ import (
|
|||||||
"gopkg.in/yaml.v2"
|
"gopkg.in/yaml.v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// File represents a YAML configuration file that namespaces all Clair
|
||||||
|
// configuration under the top-level "clair" key.
|
||||||
|
type File struct {
|
||||||
|
Clair Config `yaml:"clair"`
|
||||||
|
}
|
||||||
|
|
||||||
// Config is the global configuration for an instance of Clair.
|
// Config is the global configuration for an instance of Clair.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Database *DatabaseConfig
|
Database *DatabaseConfig
|
||||||
@ -97,11 +103,14 @@ func Load(path string) (config *Config, err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err = yaml.Unmarshal(d, config)
|
var cfgFile File
|
||||||
|
err = yaml.Unmarshal(d, &cfgFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
config = &cfgFile.Clair
|
||||||
|
|
||||||
|
// Generate a pagination key if none is provided.
|
||||||
if config.API.PaginationKey == "" {
|
if config.API.PaginationKey == "" {
|
||||||
var key fernet.Key
|
var key fernet.Key
|
||||||
if err = key.Generate(); err != nil {
|
if err = key.Generate(); err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user