| 372 | } |
| 373 | |
| 374 | func changeLogOption(daemonMap map[string]interface{}, logMaxFile, logMaxSize string) { |
| 375 | if opts, ok := daemonMap["log-opts"]; ok { |
| 376 | if len(logMaxFile) != 0 || len(logMaxSize) != 0 { |
| 377 | daemonMap["log-driver"] = "json-file" |
| 378 | } |
| 379 | optsMap, isMap := opts.(map[string]interface{}) |
| 380 | if isMap { |
| 381 | if len(logMaxFile) != 0 { |
| 382 | optsMap["max-file"] = logMaxFile |
| 383 | } else { |
| 384 | delete(optsMap, "max-file") |
| 385 | } |
| 386 | if len(logMaxSize) != 0 { |
| 387 | optsMap["max-size"] = logMaxSize |
| 388 | } else { |
| 389 | delete(optsMap, "max-size") |
| 390 | } |
| 391 | if len(optsMap) == 0 { |
| 392 | delete(daemonMap, "log-opts") |
| 393 | } |
| 394 | } else { |
| 395 | optsMap := make(map[string]interface{}) |
| 396 | if len(logMaxFile) != 0 { |
| 397 | optsMap["max-file"] = logMaxFile |
| 398 | } |
| 399 | if len(logMaxSize) != 0 { |
| 400 | optsMap["max-size"] = logMaxSize |
| 401 | } |
| 402 | if len(optsMap) != 0 { |
| 403 | daemonMap["log-opts"] = optsMap |
| 404 | } |
| 405 | } |
| 406 | } else { |
| 407 | if len(logMaxFile) != 0 || len(logMaxSize) != 0 { |
| 408 | daemonMap["log-driver"] = "json-file" |
| 409 | } |
| 410 | optsMap := make(map[string]interface{}) |
| 411 | if len(logMaxFile) != 0 { |
| 412 | optsMap["max-file"] = logMaxFile |
| 413 | } |
| 414 | if len(logMaxSize) != 0 { |
| 415 | optsMap["max-size"] = logMaxSize |
| 416 | } |
| 417 | if len(optsMap) != 0 { |
| 418 | daemonMap["log-opts"] = optsMap |
| 419 | } |
| 420 | } |
| 421 | } |
| 422 | |
| 423 | func validateDockerConfig() error { |
| 424 | if !cmd.Which("dockerd") { |