func updateControllerDetailsFromLogin( store jujuclient.ControllerStore, controllerName string, controllerDetails *jujuclient.ControllerDetails, params UpdateControllerParams, ) error { // Get the new endpoint addresses. addrs, unresolvedAddrs, addrsChanged := PrepareEndpointsForCaching(*controllerDetails, params.CurrentHostPorts, params.AddrConnectedTo...) agentChanged := params.AgentVersion != controllerDetails.AgentVersion if !addrsChanged && !agentChanged && params.ModelCount == nil && params.MachineCount == nil && params.ControllerMachineCount == nil { return nil } // Write the new controller data. if addrsChanged { controllerDetails.APIEndpoints = addrs controllerDetails.UnresolvedAPIEndpoints = unresolvedAddrs } if agentChanged { controllerDetails.AgentVersion = params.AgentVersion } if params.ModelCount != nil { controllerDetails.ModelCount = params.ModelCount } if params.MachineCount != nil { controllerDetails.MachineCount = params.MachineCount } if params.ControllerMachineCount != nil { controllerDetails.ControllerMachineCount = *params.ControllerMachineCount } err := store.UpdateController(controllerName, *controllerDetails) return errors.Trace(err) }
func updateControllerAddresses( store jujuclient.ControllerStore, controllerName string, controllerDetails *jujuclient.ControllerDetails, currentHostPorts [][]network.HostPort, addrConnectedTo ...network.HostPort, ) error { // Get the new endpoint addresses. addrs, hosts, addrsChanged := PrepareEndpointsForCaching(*controllerDetails, currentHostPorts, addrConnectedTo...) if !addrsChanged { return nil } // Write the new controller data. controllerDetails.UnresolvedAPIEndpoints = hosts controllerDetails.APIEndpoints = addrs err := store.UpdateController(controllerName, *controllerDetails) return errors.Trace(err) }