MCPcopy Create free account
hub / github.com/1Panel-dev/1Panel / changeLogOption

Function changeLogOption

agent/app/service/docker.go:374–421  ·  view source on GitHub ↗
(daemonMap map[string]interface{}, logMaxFile, logMaxSize string)

Source from the content-addressed store, hash-verified

372}
373
374func 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
423func validateDockerConfig() error {
424 if !cmd.Which("dockerd") {

Callers 1

UpdateLogOptionMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected