mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
750f0d1648
Configuration over the API per container is intentionally left out for the time being, but is supported to configure the default from the daemon config. Signed-off-by: Brian Goff <cpuguy83@gmail.com> (cherry picked from commit cbecf48bc352e680a5390a7ca9cff53098cd16d7) Signed-off-by: Madhu Venugopal <madhu@docker.com>
40 lines
961 B
Go
40 lines
961 B
Go
package cache
|
|
|
|
import (
|
|
"strconv"
|
|
|
|
"github.com/docker/docker/daemon/logger"
|
|
"github.com/docker/docker/daemon/logger/local"
|
|
"github.com/pkg/errors"
|
|
)
|
|
|
|
func init() {
|
|
for k, v := range local.LogOptKeys {
|
|
builtInCacheLogOpts[cachePrefix+k] = v
|
|
}
|
|
logger.AddBuiltinLogOpts(builtInCacheLogOpts)
|
|
logger.RegisterExternalValidator(validateLogCacheOpts)
|
|
}
|
|
|
|
func validateLogCacheOpts(cfg map[string]string) error {
|
|
if v := cfg[cacheDisabledKey]; v != "" {
|
|
_, err := strconv.ParseBool(v)
|
|
if err != nil {
|
|
return errors.Errorf("invalid value for option %s: %s", cacheDisabledKey, cfg[cacheDisabledKey])
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// MergeDefaultLogConfig reads the default log opts and makes sure that any caching related keys that exist there are
|
|
// added to dst.
|
|
func MergeDefaultLogConfig(dst, defaults map[string]string) {
|
|
for k, v := range defaults {
|
|
if !builtInCacheLogOpts[k] {
|
|
continue
|
|
}
|
|
if _, exists := dst[k]; !exists {
|
|
dst[k] = v
|
|
}
|
|
}
|
|
}
|