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

Commitcaafc5d

Browse files
committed
Merge branch 'main' into ides
2 parentsff10b9c +fb9dc4f commitcaafc5d

File tree

60 files changed

+1815
-1219
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+1815
-1219
lines changed

‎.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
site@coder/frontend
2+
site/src/xServices@presleyp

‎.github/dependabot.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ updates:
4141
timezone:"America/Chicago"
4242
commit-message:
4343
prefix:"chore"
44+
labels:
45+
-"dependencies"
46+
-"typescript/js"
4447
ignore:
4548
# Ignore major updates to Node.js types, because they need to
4649
# correspond to the Node.js engine version

‎.github/workflows/coder.yaml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
runs-on:ubuntu-latest
3030
steps:
3131
-uses:actions/checkout@v3
32-
-uses:actions/setup-go@v2
32+
-uses:actions/setup-go@v3
3333
with:
3434
go-version:"~1.18"
3535
-name:golangci-lint
@@ -71,7 +71,7 @@ jobs:
7171
uses:arduino/setup-protoc@v1
7272
with:
7373
version:"3.19.4"
74-
-uses:actions/setup-go@v2
74+
-uses:actions/setup-go@v3
7575
with:
7676
go-version:"~1.18"
7777
-run:curl -sSL
@@ -123,7 +123,7 @@ jobs:
123123
steps:
124124
-uses:actions/checkout@v3
125125

126-
-uses:actions/setup-go@v2
126+
-uses:actions/setup-go@v3
127127
with:
128128
go-version:"~1.18"
129129

@@ -195,7 +195,7 @@ jobs:
195195
steps:
196196
-uses:actions/checkout@v3
197197

198-
-uses:actions/setup-go@v2
198+
-uses:actions/setup-go@v3
199199
with:
200200
go-version:"~1.18"
201201

@@ -293,7 +293,7 @@ jobs:
293293
-name:Set up Google Cloud SDK
294294
uses:google-github-actions/setup-gcloud@v0
295295

296-
-uses:actions/setup-go@v2
296+
-uses:actions/setup-go@v3
297297
with:
298298
go-version:"~1.18"
299299

@@ -367,7 +367,7 @@ jobs:
367367
js-${{ runner.os }}-
368368
369369
# Go is required for uploading the test results to datadog
370-
-uses:actions/setup-go@v2
370+
-uses:actions/setup-go@v3
371371
with:
372372
go-version:"~1.18"
373373

@@ -423,7 +423,7 @@ jobs:
423423
js-${{ runner.os }}-
424424
425425
# Go is required for uploading the test results to datadog
426-
-uses:actions/setup-go@v2
426+
-uses:actions/setup-go@v3
427427
with:
428428
go-version:"~1.18"
429429

‎.github/workflows/release.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
-uses:actions/checkout@v3
1111
with:
1212
fetch-depth:0
13-
-uses:actions/setup-go@v2
13+
-uses:actions/setup-go@v3
1414
with:
1515
go-version:"~1.18"
1616

‎agent/agent.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,11 @@ func (a *agent) run(ctx context.Context) {
103103

104104
func (a*agent)handlePeerConn(ctx context.Context,conn*peer.Conn) {
105105
gofunc() {
106-
<-a.closed
107-
_=conn.Close()
108-
}()
109-
gofunc() {
106+
select {
107+
case<-a.closed:
108+
_=conn.Close()
109+
case<-conn.Closed():
110+
}
110111
<-conn.Closed()
111112
a.connCloseWait.Done()
112113
}()

‎agent/agent_test.go

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -135,18 +135,9 @@ func TestAgent(t *testing.T) {
135135
}
136136

137137
funcsetupSSHCommand(t*testing.T,beforeArgs []string,afterArgs []string)*exec.Cmd {
138-
_,err:=exec.LookPath("socat")
139-
iferr!=nil {
140-
t.Skip("You must have socat installed to run this test!")
141-
}
142-
143138
agentConn:=setupAgent(t)
144-
145139
listener,err:=net.Listen("tcp","127.0.0.1:0")
146140
require.NoError(t,err)
147-
t.Cleanup(func() {
148-
_=listener.Close()
149-
})
150141
gofunc() {
151142
for {
152143
conn,err:=listener.Accept()
@@ -162,7 +153,12 @@ func setupSSHCommand(t *testing.T, beforeArgs []string, afterArgs []string) *exe
162153
t.Cleanup(func() {
163154
_=listener.Close()
164155
})
165-
args:=append(beforeArgs,"-o","ProxyCommand socat - TCP4:"+listener.Addr().String(),"-o","StrictHostKeyChecking=no","host")
156+
tcpAddr,valid:=listener.Addr().(*net.TCPAddr)
157+
require.True(t,valid)
158+
args:=append(beforeArgs,
159+
"-o","HostName "+tcpAddr.IP.String(),
160+
"-o","Port "+strconv.Itoa(tcpAddr.Port),
161+
"-o","StrictHostKeyChecking=no","host")
166162
args=append(args,afterArgs...)
167163
returnexec.Command("ssh",args...)
168164
}

‎cli/cliui/prompt.go

Lines changed: 40 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"github.com/bgentry/speakeasy"
1414
"github.com/mattn/go-isatty"
1515
"github.com/spf13/cobra"
16+
"golang.org/x/xerrors"
1617
)
1718

1819
// PromptOptions supply a set of options to the prompt.
@@ -47,7 +48,7 @@ func Prompt(cmd *cobra.Command, opts PromptOptions) (string, error) {
4748
ifopts.Secret&&isInputFile&&isatty.IsTerminal(inFile.Fd()) {
4849
line,err=speakeasy.Ask("")
4950
}else {
50-
ifruntime.GOOS=="darwin"&&isInputFile {
51+
if!opts.IsConfirm&&runtime.GOOS=="darwin"&&isInputFile {
5152
varrestorefunc()
5253
restore,err=removeLineLengthLimit(int(inFile.Fd()))
5354
iferr!=nil {
@@ -64,37 +65,7 @@ func Prompt(cmd *cobra.Command, opts PromptOptions) (string, error) {
6465
// This enables multiline JSON to be pasted into an input, and have
6566
// it parse properly.
6667
iferr==nil&& (strings.HasPrefix(line,"{")||strings.HasPrefix(line,"[")) {
67-
vardata bytes.Buffer
68-
for {
69-
_,_=data.WriteString(line)
70-
varrawMessage json.RawMessage
71-
err=json.Unmarshal(data.Bytes(),&rawMessage)
72-
iferr!=nil {
73-
iferr.Error()!="unexpected end of JSON input" {
74-
err=nil
75-
line=data.String()
76-
break
77-
}
78-
79-
// Read line-by-line. We can't use a JSON decoder
80-
// here because it doesn't work by newline, so
81-
// reads will block.
82-
line,err=reader.ReadString('\n')
83-
iferr!=nil {
84-
break
85-
}
86-
continue
87-
}
88-
// Compacting the JSON makes it easier for parsing and testing.
89-
bytes:=data.Bytes()
90-
data.Reset()
91-
err=json.Compact(&data,bytes)
92-
iferr!=nil {
93-
break
94-
}
95-
line=data.String()
96-
break
97-
}
68+
line,err=promptJSON(reader,line)
9869
}
9970
}
10071
iferr!=nil {
@@ -113,7 +84,7 @@ func Prompt(cmd *cobra.Command, opts PromptOptions) (string, error) {
11384
return"",err
11485
caseline:=<-lineCh:
11586
ifopts.IsConfirm&&line!="yes"&&line!="y" {
116-
returnline,Canceled
87+
returnline,xerrors.Errorf("got %q: %w",line,Canceled)
11788
}
11889
ifopts.Validate!=nil {
11990
err:=opts.Validate(line)
@@ -131,3 +102,39 @@ func Prompt(cmd *cobra.Command, opts PromptOptions) (string, error) {
131102
return"",Canceled
132103
}
133104
}
105+
106+
funcpromptJSON(reader*bufio.Reader,linestring) (string,error) {
107+
vardata bytes.Buffer
108+
for {
109+
_,_=data.WriteString(line)
110+
varrawMessage json.RawMessage
111+
err:=json.Unmarshal(data.Bytes(),&rawMessage)
112+
iferr!=nil {
113+
iferr.Error()!="unexpected end of JSON input" {
114+
// If a real syntax error occurs in JSON,
115+
// we want to return that partial line to the user.
116+
err=nil
117+
line=data.String()
118+
break
119+
}
120+
121+
// Read line-by-line. We can't use a JSON decoder
122+
// here because it doesn't work by newline, so
123+
// reads will block.
124+
line,err=reader.ReadString('\n')
125+
iferr!=nil {
126+
break
127+
}
128+
continue
129+
}
130+
// Compacting the JSON makes it easier for parsing and testing.
131+
rawJSON:=data.Bytes()
132+
data.Reset()
133+
err=json.Compact(&data,rawJSON)
134+
iferr!=nil {
135+
returnline,xerrors.Errorf("compact json: %w",err)
136+
}
137+
returndata.String(),nil
138+
}
139+
returnline,nil
140+
}

‎cli/cliui/resources_test.go

Lines changed: 62 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -8,76 +8,83 @@ import (
88
"github.com/coder/coder/coderd/database"
99
"github.com/coder/coder/codersdk"
1010
"github.com/coder/coder/pty/ptytest"
11+
"github.com/stretchr/testify/require"
1112
)
1213

1314
funcTestWorkspaceResources(t*testing.T) {
1415
t.Parallel()
1516
t.Run("SingleAgentSSH",func(t*testing.T) {
1617
t.Parallel()
1718
ptty:=ptytest.New(t)
18-
cliui.WorkspaceResources(ptty.Output(), []codersdk.WorkspaceResource{{
19-
Type:"google_compute_instance",
20-
Name:"dev",
21-
Transition:database.WorkspaceTransitionStart,
22-
Agents: []codersdk.WorkspaceAgent{{
23-
Name:"dev",
24-
Status:codersdk.WorkspaceAgentConnected,
25-
Architecture:"amd64",
26-
OperatingSystem:"linux",
27-
}},
28-
}}, cliui.WorkspaceResourcesOptions{
29-
WorkspaceName:"example",
30-
})
19+
gofunc() {
20+
err:=cliui.WorkspaceResources(ptty.Output(), []codersdk.WorkspaceResource{{
21+
Type:"google_compute_instance",
22+
Name:"dev",
23+
Transition:database.WorkspaceTransitionStart,
24+
Agents: []codersdk.WorkspaceAgent{{
25+
Name:"dev",
26+
Status:codersdk.WorkspaceAgentConnected,
27+
Architecture:"amd64",
28+
OperatingSystem:"linux",
29+
}},
30+
}}, cliui.WorkspaceResourcesOptions{
31+
WorkspaceName:"example",
32+
})
33+
require.NoError(t,err)
34+
}()
3135
ptty.ExpectMatch("coder ssh example")
3236
})
3337

3438
t.Run("MultipleStates",func(t*testing.T) {
3539
t.Parallel()
3640
ptty:=ptytest.New(t)
3741
disconnected:=database.Now().Add(-4*time.Second)
38-
cliui.WorkspaceResources(ptty.Output(), []codersdk.WorkspaceResource{{
39-
Address:"disk",
40-
Transition:database.WorkspaceTransitionStart,
41-
Type:"google_compute_disk",
42-
Name:"root",
43-
}, {
44-
Address:"disk",
45-
Transition:database.WorkspaceTransitionStop,
46-
Type:"google_compute_disk",
47-
Name:"root",
48-
}, {
49-
Address:"another",
50-
Transition:database.WorkspaceTransitionStart,
51-
Type:"google_compute_instance",
52-
Name:"dev",
53-
Agents: []codersdk.WorkspaceAgent{{
54-
CreatedAt:database.Now().Add(-10*time.Second),
55-
Status:codersdk.WorkspaceAgentConnecting,
56-
Name:"dev",
57-
OperatingSystem:"linux",
58-
Architecture:"amd64",
59-
}},
60-
}, {
61-
Transition:database.WorkspaceTransitionStart,
62-
Type:"kubernetes_pod",
63-
Name:"dev",
64-
Agents: []codersdk.WorkspaceAgent{{
65-
Status:codersdk.WorkspaceAgentConnected,
66-
Name:"go",
67-
Architecture:"amd64",
68-
OperatingSystem:"linux",
42+
gofunc() {
43+
err:=cliui.WorkspaceResources(ptty.Output(), []codersdk.WorkspaceResource{{
44+
Address:"disk",
45+
Transition:database.WorkspaceTransitionStart,
46+
Type:"google_compute_disk",
47+
Name:"root",
6948
}, {
70-
DisconnectedAt:&disconnected,
71-
Status:codersdk.WorkspaceAgentDisconnected,
72-
Name:"postgres",
73-
Architecture:"amd64",
74-
OperatingSystem:"linux",
75-
}},
76-
}}, cliui.WorkspaceResourcesOptions{
77-
WorkspaceName:"dev",
78-
HideAgentState:false,
79-
HideAccess:false,
80-
})
49+
Address:"disk",
50+
Transition:database.WorkspaceTransitionStop,
51+
Type:"google_compute_disk",
52+
Name:"root",
53+
}, {
54+
Address:"another",
55+
Transition:database.WorkspaceTransitionStart,
56+
Type:"google_compute_instance",
57+
Name:"dev",
58+
Agents: []codersdk.WorkspaceAgent{{
59+
CreatedAt:database.Now().Add(-10*time.Second),
60+
Status:codersdk.WorkspaceAgentConnecting,
61+
Name:"dev",
62+
OperatingSystem:"linux",
63+
Architecture:"amd64",
64+
}},
65+
}, {
66+
Transition:database.WorkspaceTransitionStart,
67+
Type:"kubernetes_pod",
68+
Name:"dev",
69+
Agents: []codersdk.WorkspaceAgent{{
70+
Status:codersdk.WorkspaceAgentConnected,
71+
Name:"go",
72+
Architecture:"amd64",
73+
OperatingSystem:"linux",
74+
}, {
75+
DisconnectedAt:&disconnected,
76+
Status:codersdk.WorkspaceAgentDisconnected,
77+
Name:"postgres",
78+
Architecture:"amd64",
79+
OperatingSystem:"linux",
80+
}},
81+
}}, cliui.WorkspaceResourcesOptions{
82+
WorkspaceName:"dev",
83+
HideAgentState:false,
84+
HideAccess:false,
85+
})
86+
require.NoError(t,err)
87+
}()
8188
ptty.ExpectMatch("google_compute_disk.root")
8289
ptty.ExpectMatch("google_compute_instance.dev")
8390
ptty.ExpectMatch("coder ssh dev.postgres")

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp