MCPcopy Create free account
hub / github.com/devnullvoid/pvetui / getClientForNode

Method getClientForNode

internal/ui/components/app.go:649–669  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

647// In group mode, it returns the client for the Node's source profile.
648// In single-profile mode, it returns the main client.
649func (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.
672func (a *App) createSyntheticGroup(nodes []*api.Node) *api.Cluster {

Callers 14

refreshNodeDataMethod · 0.95
enqueueVMCreateMethod · 0.95
connectToNodeVNCMethod · 0.95
openNodeVNCMethod · 0.95
NewAppFunction · 0.95
StartBackupMonitorMethod · 0.95

Calls 3

snapConnMethod · 0.95
GetClientMethod · 0.80
GetStatusMethod · 0.80

Tested by

no test coverage detected