github.com/Heebron/moby@v0.0.0-20221111184709-6eab4f55faf7/daemon/logger/loggerutils/cache/validate.go (about) 1 package cache 2 3 import ( 4 "strconv" 5 6 "github.com/docker/docker/daemon/logger" 7 "github.com/docker/docker/daemon/logger/local" 8 "github.com/pkg/errors" 9 ) 10 11 func init() { 12 for k, v := range local.LogOptKeys { 13 builtInCacheLogOpts[cachePrefix+k] = v 14 } 15 logger.AddBuiltinLogOpts(builtInCacheLogOpts) 16 logger.RegisterExternalValidator(validateLogCacheOpts) 17 } 18 19 func validateLogCacheOpts(cfg map[string]string) error { 20 if v := cfg[cacheDisabledKey]; v != "" { 21 _, err := strconv.ParseBool(v) 22 if err != nil { 23 return errors.Errorf("invalid value for option %s: %s", cacheDisabledKey, cfg[cacheDisabledKey]) 24 } 25 } 26 return nil 27 } 28 29 // MergeDefaultLogConfig reads the default log opts and makes sure that any caching related keys that exist there are 30 // added to dst. 31 func MergeDefaultLogConfig(dst, defaults map[string]string) { 32 for k, v := range defaults { 33 if !builtInCacheLogOpts[k] { 34 continue 35 } 36 if _, exists := dst[k]; !exists { 37 dst[k] = v 38 } 39 } 40 }