aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/instance
diff options
context:
space:
mode:
authorTaras Madan <tarasmadan@google.com>2025-08-05 10:03:38 +0200
committerTaras Madan <tarasmadan@google.com>2025-08-07 10:01:30 +0000
commit04cffc22d57a9014cb89df6c9f44de50d2eb2b9b (patch)
treeb6b5ff4cd8afb9342a2fc5d8dfaff21a4766139b /pkg/instance
parenta9fce3b50a00a8dab6365de4c22749f4bd1f1ac6 (diff)
vm: refactoring
1. func Run optionally accepts the opts. 2. Some refactoring, more comments.
Diffstat (limited to 'pkg/instance')
-rw-r--r--pkg/instance/execprog.go9
1 files changed, 6 insertions, 3 deletions
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)
}