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

Method UpdateConfByFile

agent/app/service/docker.go:329–351  ·  view source on GitHub ↗
(req dto.DaemonJsonUpdateByFile)

Source from the content-addressed store, hash-verified

327}
328
329func (u *DockerService) UpdateConfByFile(req dto.DaemonJsonUpdateByFile) error {
330 err := createIfNotExistDaemonJsonFile()
331 if err != nil {
332 return err
333 }
334 file, err := os.OpenFile(constant.DaemonJsonPath, os.O_WRONLY|os.O_TRUNC, 0640)
335 if err != nil {
336 return err
337 }
338 defer file.Close()
339 write := bufio.NewWriter(file)
340 _, _ = write.WriteString(req.File)
341 write.Flush()
342
343 if err := validateDockerConfig(); err != nil {
344 return err
345 }
346
347 if err := controller.HandleRestart("docker"); err != nil {
348 return fmt.Errorf("failed to restart Docker: %v", err)
349 }
350 return nil
351}
352
353func (u *DockerService) OperateDocker(req dto.DockerOperation) error {
354 service := "docker"

Callers

nothing calls this directly

Calls 5

validateDockerConfigFunction · 0.85
OpenFileMethod · 0.80
CloseMethod · 0.65
FlushMethod · 0.45

Tested by

no test coverage detected