Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat: Add support for VS Code and JetBrains Gateway via SSH #956

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

Merged
merged 18 commits into from
Apr 12, 2022
Merged
Show file tree
Hide file tree
Changes from 2 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
13 changes: 8 additions & 5 deletions cli/ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"io"
"net"
"os"
"strings"
"time"

"github.com/google/uuid"
Expand All @@ -26,14 +27,16 @@ func ssh() *cobra.Command {
stdio bool
)
cmd := &cobra.Command{
Use: "ssh <workspace> [agent]",
Use: "ssh <workspace>",
Args: cobra.MinimumNArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
client, err := createClient(cmd)
if err != nil {
return err
}

workspace, err := client.WorkspaceByName(cmd.Context(), codersdk.Me, args[0])
workspaceParts := strings.Split(args[0], ".")
workspace, err := client.WorkspaceByName(cmd.Context(), codersdk.Me, workspaceParts[0])
if err != nil {
return err
}
Expand Down Expand Up @@ -66,16 +69,16 @@ func ssh() *cobra.Command {
return xerrors.New("workspace has no agents")
}
var agent codersdk.WorkspaceAgent
if len(args) >= 2 {
if len(workspaceParts) >= 2 {
for _, otherAgent := range agents {
if otherAgent.Name != args[1] {
if otherAgent.Name != workspaceParts[1] {
continue
}
agent = otherAgent
break
}
if agent.ID == uuid.Nil {
return xerrors.Errorf("agent not found by name %q", args[1])
return xerrors.Errorf("agent not found by name %q", workspaceParts[1])
}
}
if agent.ID == uuid.Nil {
Expand Down
7 changes: 6 additions & 1 deletion provisioner/terraform/provision_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"encoding/json"
"os"
"path/filepath"
"sort"
"testing"

"github.com/stretchr/testify/require"
Expand All @@ -27,7 +28,7 @@ terraform {
required_providers {
coder = {
source = "coder/coder"
version = "0.3"
version = "0.3.1"
}
}
}
Expand Down Expand Up @@ -390,6 +391,10 @@ provider "coder" {

// Remove randomly generated data.
for _, resource := range msg.GetComplete().Resources {
sort.Slice(resource.Agents, func(i, j int) bool {
return resource.Agents[i].Name < resource.Agents[j].Name
})

for _, agent := range resource.Agents {
agent.Id = ""
if agent.GetToken() == "" {
Expand Down