MCPcopy Create free account
hub / github.com/encodeous/nylon / Exec

Method Exec

e2e/harness.go:338–369  ·  view source on GitHub ↗
(nodeName string, cmd []string)

Source from the content-addressed store, hash-verified

336 }
337}
338func (h *Harness) Exec(nodeName string, cmd []string) (string, string, error) {
339 h.mu.Lock()
340 container, ok := h.Nodes[nodeName]
341 h.mu.Unlock()
342
343 if !ok {
344 return "", "", fmt.Errorf("node %s not found", nodeName)
345 }
346
347 code, r, err := container.Exec(h.ctx, cmd)
348 if err != nil {
349 return "", "", err
350 }
351
352 stdoutBuf := new(bytes.Buffer)
353 stderrBuf := new(bytes.Buffer)
354
355 // Demultiplex the stream using stdcopy
356 _, err = stdcopy.StdCopy(stdoutBuf, stderrBuf, r)
357 if err != nil {
358 return "", "", fmt.Errorf("failed to copy output: %w", err)
359 }
360
361 stdout := StripAnsi(stdoutBuf.String())
362 stderr := StripAnsi(stderrBuf.String())
363
364 if code != 0 {
365 return stdout, stderr, fmt.Errorf("command exited with code %d: %s\nStderr: %s", code, stdout, stderr)
366 }
367
368 return stdout, stderr, nil
369}
370
371type BackgroundExec struct {
372 Stdout string

Callers 12

TestRecoveryExampleFunction · 0.95
WaitForStatusMethod · 0.95
ReadStatusMethod · 0.95
ExecBackgroundMethod · 0.95
TestConnectivityFunction · 0.95
TestPassiveRoamingFunction · 0.95
TestDistributionFunction · 0.95
TestHealthcheckPingFunction · 0.95
TestEndpointResolutionFunction · 0.95
TestDynamicResolutionFunction · 0.95
readCentralTimestampFunction · 0.80

Calls 2

StripAnsiFunction · 0.85
StringMethod · 0.45

Tested by 9

TestRecoveryExampleFunction · 0.76
TestConnectivityFunction · 0.76
TestPassiveRoamingFunction · 0.76
TestDistributionFunction · 0.76
TestHealthcheckPingFunction · 0.76
TestEndpointResolutionFunction · 0.76
TestDynamicResolutionFunction · 0.76
readCentralTimestampFunction · 0.64