package children import ( "errors" "fmt" "isle/bootstrap" "isle/daemon/daecommon" "reflect" ) // ReloadDiff describes which children had their configurations changed as part // of a change in the bootstrap. type ReloadDiff struct { NebulaChanged bool DNSChanged bool } // CalculateReloadDiff calculates a ReloadDiff based on an old and new // bootstrap. func CalculateReloadDiff( daemonConfig daecommon.Config, prevBootstrap, nextBootstrap bootstrap.Bootstrap, ) ( diff ReloadDiff, err error, ) { { prevNebulaConfig, prevErr := nebulaConfig(daemonConfig, prevBootstrap) nextNebulaConfig, nextErr := nebulaConfig(daemonConfig, nextBootstrap) if err = errors.Join(prevErr, nextErr); err != nil { err = fmt.Errorf("calculating nebula config: %w", err) return } diff.NebulaChanged = !reflect.DeepEqual( prevNebulaConfig, nextNebulaConfig, ) } { diff.DNSChanged = !reflect.DeepEqual( dnsmasqConfig(daemonConfig, prevBootstrap), dnsmasqConfig(daemonConfig, nextBootstrap), ) } return }