-
Notifications
You must be signed in to change notification settings - Fork 0
Use agent workspace for kubeoc attach #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -305,8 +305,12 @@ func runAgentAttachServiceProxy(ctx context.Context, namespace, agentName string | |
| heartbeatCancel := startConnectionHeartbeat(ctx, k8sClient, namespace, agentName) | ||
| defer heartbeatCancel() | ||
|
|
||
| // Launch opencode attach | ||
| attachCmd := exec.CommandContext(ctx, "opencode", "attach", localURL) //nolint:gosec // args are not user-controlled | ||
| // Launch opencode attach from the Agent workspace directory when configured. | ||
| attachArgs := []string{"attach", localURL} | ||
| if agent.Spec.WorkspaceDir != "" { | ||
| attachArgs = append(attachArgs, "--dir", agent.Spec.WorkspaceDir) | ||
| } | ||
| attachCmd := exec.CommandContext(ctx, "opencode", attachArgs...) //nolint:gosec // args are not user-controlled | ||
|
||
| attachCmd.Stdin = os.Stdin | ||
| attachCmd.Stdout = os.Stdout | ||
| attachCmd.Stderr = os.Stderr | ||
|
|
@@ -411,7 +415,11 @@ func runAgentAttachPortForward(ctx context.Context, namespace, agentName string, | |
| heartbeatCancel := startConnectionHeartbeat(ctx, k8sClient, namespace, agentName) | ||
| defer heartbeatCancel() | ||
|
|
||
| attachCmd := exec.CommandContext(ctx, "opencode", "attach", localURL) //nolint:gosec // args are not user-controlled | ||
| attachArgs := []string{"attach", localURL} | ||
| if agent.Spec.WorkspaceDir != "" { | ||
| attachArgs = append(attachArgs, "--dir", agent.Spec.WorkspaceDir) | ||
| } | ||
|
Comment on lines
+418
to
+421
|
||
| attachCmd := exec.CommandContext(ctx, "opencode", attachArgs...) //nolint:gosec // args are not user-controlled | ||
|
||
| attachCmd.Stdin = os.Stdin | ||
| attachCmd.Stdout = os.Stdout | ||
| attachCmd.Stderr = os.Stderr | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WorkspaceDir can be inherited via agent.spec.templateRef (AgentTemplate). This code only checks agent.Spec.WorkspaceDir, so attach won’t pass --dir when WorkspaceDir is set on the template (effective workspace differs from what the controller uses). Consider resolving the merged config (e.g., controller.ResolveAgentConfigFromTemplate) and using the resulting workspaceDir instead of reading Agent.Spec directly.