(req dto.LogOption)
| 257 | } |
| 258 | |
| 259 | func (u *DockerService) UpdateLogOption(req dto.LogOption) error { |
| 260 | err := createIfNotExistDaemonJsonFile() |
| 261 | if err != nil { |
| 262 | return err |
| 263 | } |
| 264 | file, err := os.ReadFile(constant.DaemonJsonPath) |
| 265 | if err != nil { |
| 266 | return err |
| 267 | } |
| 268 | daemonMap := make(map[string]interface{}) |
| 269 | _ = json.Unmarshal(file, &daemonMap) |
| 270 | |
| 271 | changeLogOption(daemonMap, req.LogMaxFile, req.LogMaxSize) |
| 272 | newJson, err := json.MarshalIndent(daemonMap, "", "\t") |
| 273 | if err != nil { |
| 274 | return err |
| 275 | } |
| 276 | if err := os.WriteFile(constant.DaemonJsonPath, newJson, 0640); err != nil { |
| 277 | return err |
| 278 | } |
| 279 | |
| 280 | if err := validateDockerConfig(); err != nil { |
| 281 | return err |
| 282 | } |
| 283 | |
| 284 | if err := controller.HandleRestart("docker"); err != nil { |
| 285 | return fmt.Errorf("failed to restart Docker: %v", err) |
| 286 | } |
| 287 | return nil |
| 288 | } |
| 289 | |
| 290 | func (u *DockerService) UpdateIpv6Option(req dto.Ipv6Option) error { |
| 291 | err := createIfNotExistDaemonJsonFile() |
nothing calls this directly
no test coverage detected