(ctx context.Context, clusterId string, address string)
| 50 | } |
| 51 | |
| 52 | func (m *imlClusterModule) ResetCluster(ctx context.Context, clusterId string, address string) ([]*cluster_dto.Node, error) { |
| 53 | |
| 54 | nodes, err := m.clusterService.UpdateAddress(ctx, clusterId, address) |
| 55 | if err != nil { |
| 56 | return nil, err |
| 57 | } |
| 58 | err = m.initGateway(ctx, clusterId) |
| 59 | if err != nil { |
| 60 | return nil, err |
| 61 | } |
| 62 | nodesOut := utils.SliceToSlice(nodes, func(i *cluster.Node) *cluster_dto.Node { |
| 63 | return &cluster_dto.Node{ |
| 64 | Id: i.Uuid, |
| 65 | Name: i.Name, |
| 66 | Admins: i.Admin, |
| 67 | Peers: i.Peer, |
| 68 | Gateways: i.Server, |
| 69 | } |
| 70 | }) |
| 71 | v, has := m.settingService.Get(ctx, setting.KeyInvokeAddress) |
| 72 | if (!has || v == "") && len(nodesOut) > 0 && len(nodesOut[0].Gateways) > 0 { |
| 73 | m.settingService.Set(ctx, setting.KeyInvokeAddress, nodesOut[0].Gateways[0], utils.UserId(ctx)) |
| 74 | } |
| 75 | nodeStatus(ctx, nodesOut) |
| 76 | return nodesOut, nil |
| 77 | } |
| 78 | func (m *imlClusterModule) initGateway(ctx context.Context, clusterId string) error { |
| 79 | client, err := m.clusterService.GatewayClient(ctx, clusterId) |
| 80 | if err != nil { |
nothing calls this directly
no test coverage detected