2019-06-20 18:36:40 -05:00
|
|
|
package api
|
|
|
|
|
|
|
|
import (
|
|
|
|
dspec "github.com/opencontainers/distribution-spec"
|
|
|
|
)
|
|
|
|
|
2019-09-16 13:01:59 -05:00
|
|
|
//nolint (gochecknoglobals)
|
|
|
|
var Commit string
|
|
|
|
|
2019-06-20 18:36:40 -05:00
|
|
|
type StorageConfig struct {
|
|
|
|
RootDirectory string
|
|
|
|
}
|
|
|
|
|
|
|
|
type TLSConfig struct {
|
|
|
|
Cert string
|
|
|
|
Key string
|
|
|
|
CACert string
|
|
|
|
}
|
|
|
|
|
|
|
|
type AuthHTPasswd struct {
|
|
|
|
Path string
|
|
|
|
}
|
|
|
|
|
|
|
|
type AuthConfig struct {
|
|
|
|
FailDelay int
|
|
|
|
HTPasswd AuthHTPasswd
|
|
|
|
}
|
|
|
|
|
|
|
|
type HTTPConfig struct {
|
2019-08-28 16:05:16 -05:00
|
|
|
Address string
|
|
|
|
Port string
|
|
|
|
TLS TLSConfig `mapstructure:",omitempty"`
|
|
|
|
Auth AuthConfig `mapstructure:",omitempty"`
|
|
|
|
Realm string
|
|
|
|
AllowReadAccess bool `mapstructure:",omitempty"`
|
2019-06-20 18:36:40 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
type LogConfig struct {
|
|
|
|
Level string
|
|
|
|
Output string
|
|
|
|
}
|
|
|
|
|
|
|
|
type Config struct {
|
|
|
|
Version string
|
2019-09-16 13:01:59 -05:00
|
|
|
Commit string
|
2019-06-20 18:36:40 -05:00
|
|
|
Storage StorageConfig
|
|
|
|
HTTP HTTPConfig
|
|
|
|
Log LogConfig `mapstructure:",omitempty"`
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewConfig() *Config {
|
|
|
|
return &Config{
|
|
|
|
Version: dspec.Version,
|
2019-09-16 13:01:59 -05:00
|
|
|
Commit: Commit,
|
2019-06-20 18:36:40 -05:00
|
|
|
HTTP: HTTPConfig{Address: "127.0.0.1", Port: "8080"},
|
|
|
|
Log: LogConfig{Level: "debug"},
|
|
|
|
}
|
|
|
|
}
|