Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions pkg/cmd/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,12 @@ func (e *ExecExitError) Error() string {

// execRequest represents the JSON body for exec requests
type execRequest struct {
Command []string `json:"command"`
TTY bool `json:"tty"`
Env map[string]string `json:"env,omitempty"`
Cwd string `json:"cwd,omitempty"`
Timeout int32 `json:"timeout,omitempty"`
Command []string `json:"command"`
TTY bool `json:"tty"`
Env map[string]string `json:"env,omitempty"`
Cwd string `json:"cwd,omitempty"`
Timeout int32 `json:"timeout,omitempty"`
WaitForAgent int32 `json:"wait_for_agent"`
}

var execCmd = cli.Command{
Expand Down Expand Up @@ -65,6 +66,11 @@ var execCmd = cli.Command{
Name: "timeout",
Usage: "Execution timeout in seconds (0 = no timeout)",
},
&cli.IntFlag{
Name: "wait-for-agent",
Usage: "Seconds to wait for guest agent to be ready (0 = fail immediately)",
Value: 30, // Default: wait up to 30 seconds for agent
},
},
Action: handleExec,
HideHelpCommand: true,
Expand Down Expand Up @@ -126,6 +132,7 @@ func handleExec(ctx context.Context, cmd *cli.Command) error {
if timeout := cmd.Int("timeout"); timeout > 0 {
execReq.Timeout = int32(timeout)
}
execReq.WaitForAgent = int32(cmd.Int("wait-for-agent"))

reqBody, err := json.Marshal(execReq)
if err != nil {
Expand Down