getClientForNode returns the appropriate API client for a Node. In group mode, it returns the client for the Node's source profile. In single-profile mode, it returns the main client.
(node *api.Node)
| 647 | // In group mode, it returns the client for the Node's source profile. |
| 648 | // In single-profile mode, it returns the main client. |
| 649 | func (a *App) getClientForNode(node *api.Node) (*api.Client, error) { |
| 650 | conn := a.snapConn() |
| 651 | if conn.isGroupMode { |
| 652 | if node.SourceProfile == "" { |
| 653 | return nil, fmt.Errorf("source profile not set for Node %s in group mode", node.Name) |
| 654 | } |
| 655 | |
| 656 | profileClient, exists := conn.groupManager.GetClient(node.SourceProfile) |
| 657 | if !exists { |
| 658 | return nil, fmt.Errorf("profile '%s' not found in group manager", node.SourceProfile) |
| 659 | } |
| 660 | |
| 661 | status, err := profileClient.GetStatus() |
| 662 | if status != api.ProfileStatusConnected { |
| 663 | return nil, fmt.Errorf("profile '%s' is not connected: %v (error: %v)", node.SourceProfile, status, err) |
| 664 | } |
| 665 | |
| 666 | return profileClient.Client, nil |
| 667 | } |
| 668 | return conn.client, nil |
| 669 | } |
| 670 | |
| 671 | // createSyntheticGroup creates a synthetic cluster object from a list of nodes for group display. |
| 672 | func (a *App) createSyntheticGroup(nodes []*api.Node) *api.Cluster { |
no test coverage detected