From 04cffc22d57a9014cb89df6c9f44de50d2eb2b9b Mon Sep 17 00:00:00 2001 From: Taras Madan Date: Tue, 5 Aug 2025 10:03:38 +0200 Subject: vm: refactoring 1. func Run optionally accepts the opts. 2. Some refactoring, more comments. --- pkg/instance/execprog.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'pkg/instance/execprog.go') diff --git a/pkg/instance/execprog.go b/pkg/instance/execprog.go index 83461d07e..0b9f9ebf7 100644 --- a/pkg/instance/execprog.go +++ b/pkg/instance/execprog.go @@ -120,13 +120,16 @@ func (inst *ExecProgInstance) runCommand(command string, duration time.Duration, command = inst.StraceBin + filterCalls + ` -s 100 -x -f ` + command prefixOutput = []byte(fmt.Sprintf("%s\n\n<...>\n", command)) } - opts := []any{exitCondition} + optionalBeforeContext := func(*vm.RunOptions) {} if inst.BeforeContextLen != 0 { - opts = append(opts, vm.OutputSize(inst.BeforeContextLen)) + optionalBeforeContext = vm.WithBeforeContext(inst.BeforeContextLen) } ctxTimeout, cancel := context.WithTimeout(context.Background(), duration) defer cancel() - output, rep, err := inst.VMInstance.Run(ctxTimeout, inst.reporter, command, opts...) + output, rep, err := inst.VMInstance.Run(ctxTimeout, inst.reporter, command, + vm.WithExitCondition(exitCondition), + optionalBeforeContext, + ) if err != nil { return nil, fmt.Errorf("failed to run command in VM: %w", err) } -- cgit mrf-deployment