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

Method GetGroupData

pkg/api/group-client-operations.go:203–223  ·  view source on GitHub ↗

GetGroupData is a helper for executing an operation and grouping results. It executes the operation on all connected profiles and returns combined results. The groupFunc receives all successful results and should combine them.

(
	ctx context.Context,
	operation ProfileOperation,
	groupFunc func(results []ProfileResult) (interface{}, error),
)

Source from the content-addressed store, hash-verified

201// It executes the operation on all connected profiles and returns combined results.
202// The groupFunc receives all successful results and should combine them.
203func (m *GroupClientManager) GetGroupData(
204 ctx context.Context,
205 operation ProfileOperation,
206 groupFunc func(results []ProfileResult) (interface{}, error),
207) (interface{}, error) {
208 results := m.ExecuteOnAllProfiles(ctx, operation)
209
210 // Filter successful results
211 successfulResults := make([]ProfileResult, 0, len(results))
212 for _, result := range results {
213 if result.Success {
214 successfulResults = append(successfulResults, result)
215 }
216 }
217
218 if len(successfulResults) == 0 {
219 return nil, fmt.Errorf("no profiles returned successful results")
220 }
221
222 return groupFunc(successfulResults)
223}

Callers 3

GetGroupNodesMethod · 0.95
GetGroupVMsMethod · 0.95
GetGroupTasksMethod · 0.95

Calls 1

ExecuteOnAllProfilesMethod · 0.95

Tested by

no test coverage detected