SetConfig updates the interface configuration
(config *types.NetworkConfig)
| 349 | |
| 350 | // SetConfig updates the interface configuration |
| 351 | func (im *InterfaceManager) SetConfig(config *types.NetworkConfig) error { |
| 352 | if config == nil { |
| 353 | return fmt.Errorf("config cannot be nil") |
| 354 | } |
| 355 | |
| 356 | // Validate and set defaults |
| 357 | if err := confparser.SetDefaultsAndValidate(config); err != nil { |
| 358 | return fmt.Errorf("invalid config: %w", err) |
| 359 | } |
| 360 | |
| 361 | im.config = config |
| 362 | |
| 363 | // Apply the new configuration |
| 364 | if err := im.applyConfiguration(); err != nil { |
| 365 | im.logger.Error().Err(err).Msg("failed to apply new configuration") |
| 366 | return err |
| 367 | } |
| 368 | |
| 369 | // Notify callback |
| 370 | if im.onConfigChange != nil { |
| 371 | im.onConfigChange(config) |
| 372 | } |
| 373 | |
| 374 | im.logger.Info().Msg("configuration updated") |
| 375 | return nil |
| 376 | } |
| 377 | |
| 378 | // RenewDHCPLease renews the DHCP lease |
| 379 | func (im *InterfaceManager) RenewDHCPLease() error { |
no test coverage detected