Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix(enterprise): update external agent instructions in cli#19411

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
kacpersaw merged 2 commits intomainfromkacpersaw/fix-external-workspaces-cli
Aug 19, 2025
Merged
Show file tree
Hide file tree
Changes from1 commit
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
5 changes: 2 additions & 3 deletionsenterprise/cli/externalworkspaces.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -243,15 +243,14 @@ func fetchExternalAgents(inv *serpent.Invocation, client *codersdk.Client, works
// formatExternalAgent formats the instructions for an external agent.
func formatExternalAgent(workspaceName string, externalAgents []externalAgent) string {
var output strings.Builder
_, _ = output.WriteString(fmt.Sprintf("\nPlease run the followingcommands to attach external agent to the workspace %s:\n\n", cliui.Keyword(workspaceName)))
_, _ = output.WriteString(fmt.Sprintf("\nPlease run the followingcommand to attach external agent to the workspace %s:\n\n", cliui.Keyword(workspaceName)))

for i, agent := range externalAgents {
if len(externalAgents) > 1 {
_, _ = output.WriteString(fmt.Sprintf("For agent %s:\n", cliui.Keyword(agent.AgentName)))
}

_, _ = output.WriteString(fmt.Sprintf("%s\n", pretty.Sprint(cliui.DefaultStyles.Code, fmt.Sprintf("export CODER_AGENT_TOKEN=%s", agent.AuthToken))))
_, _ = output.WriteString(fmt.Sprintf("%s\n", pretty.Sprint(cliui.DefaultStyles.Code, fmt.Sprintf("curl -fsSL %s | sh", agent.InitScript))))
_, _ = output.WriteString(fmt.Sprintf("%s\n", pretty.Sprint(cliui.DefaultStyles.Code, agent.InitScript)))

if i < len(externalAgents)-1 {
_, _ = output.WriteString("\n")
Expand Down
21 changes: 9 additions & 12 deletionsenterprise/cli/externalworkspaces_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -162,11 +162,10 @@ func TestExternalWorkspaces(t *testing.T) {
pty.WriteLine("yes")

// Expect the external agent instructions
pty.ExpectMatch("Please run the following commands to attach external agent")
pty.ExpectMatch("export CODER_AGENT_TOKEN=")
pty.ExpectMatch("curl -fsSL")
pty.ExpectMatch("Please run the following command to attach external agent")
pty.ExpectRegexMatch("curl -fsSL .* | CODER_AGENT_TOKEN=.* sh")

<-doneChan
testutil.TryReceive(context.Background(), t,doneChan)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This needs to use a context with a timeout, e.g.ctx := testutil.Context(t, testutil.WaitLong)

Also, you should probably useRequireRecv instead for these, since you want the test to fail if the doneChan never gets closed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Nevermind, you need to useTryReceive, you're right.


// Verify the workspace was created
ws, err := member.WorkspaceByOwnerAndName(context.Background(), codersdk.Me, "my-external-workspace", codersdk.WorkspaceOptions{})
Expand DownExpand Up@@ -392,11 +391,10 @@ func TestExternalWorkspaces(t *testing.T) {
assert.NoError(t, errC)
close(done)
}()
pty.ExpectMatch("Please run the following commands to attach external agent to the workspace")
pty.ExpectMatch("export CODER_AGENT_TOKEN=")
pty.ExpectMatch("curl -fsSL")
pty.ExpectMatch("Please run the following command to attach external agent to the workspace")
pty.ExpectRegexMatch("curl -fsSL .* | CODER_AGENT_TOKEN=.* sh")
cancelFunc()
<-done
testutil.TryReceive(context.Background(), t,done)
})

t.Run("AgentInstructionsJSON", func(t *testing.T) {
Expand DownExpand Up@@ -545,11 +543,10 @@ func TestExternalWorkspaces(t *testing.T) {
pty.ExpectMatch("external-agent (linux, amd64)")

// Expect the external agent instructions
pty.ExpectMatch("Please run the following commands to attach external agent")
pty.ExpectMatch("export CODER_AGENT_TOKEN=")
pty.ExpectMatch("curl -fsSL")
pty.ExpectMatch("Please run the following command to attach external agent")
pty.ExpectRegexMatch("curl -fsSL .* | CODER_AGENT_TOKEN=.* sh")

<-doneChan
testutil.TryReceive(context.Background(), t,doneChan)

// Verify the workspace was created
ws, err := member.WorkspaceByOwnerAndName(context.Background(), codersdk.Me, "my-external-workspace", codersdk.WorkspaceOptions{})
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp