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

Commitff2b822

Browse files
committed
Merge branch 'main' into gitauth
2 parents320c10d +acf000a commitff2b822

File tree

158 files changed

+3613
-2889
lines changed

Some content is hidden

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

158 files changed

+3613
-2889
lines changed

‎.vscode/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@
113113
"stretchr",
114114
"STTY",
115115
"stuntest",
116+
"tanstack",
116117
"tailbroker",
117118
"tailcfg",
118119
"tailexchange",

‎Makefile

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ gen: \
424424
provisionerd/proto/provisionerd.pb.go\
425425
site/src/api/typesGenerated.ts\
426426
docs/admin/prometheus.md\
427-
docs/cli/coder.md\
427+
docs/cli.md\
428428
docs/admin/audit-logs.md\
429429
coderd/apidoc/swagger.json\
430430
.prettierignore.include\
@@ -444,7 +444,7 @@ gen/mark-fresh:
444444
provisionerd/proto/provisionerd.pb.go\
445445
site/src/api/typesGenerated.ts\
446446
docs/admin/prometheus.md\
447-
docs/cli/coder.md\
447+
docs/cli.md\
448448
docs/admin/audit-logs.md\
449449
coderd/apidoc/swagger.json\
450450
.prettierignore.include\
@@ -500,10 +500,11 @@ docs/admin/prometheus.md: scripts/metricsdocgen/main.go scripts/metricsdocgen/me
500500
cd site
501501
yarn run format:write:only ../docs/admin/prometheus.md
502502

503-
docs/cli/coder.md: scripts/clidocgen/main.go$(GO_SRC_FILES) docs/manifest.json
504-
BASE_PATH="." go run scripts/clidocgen/main.go
503+
docs/cli.md: scripts/clidocgen/main.go$(GO_SRC_FILES) docs/manifest.json
504+
rm -rf ./docs/cli/*.md
505+
BASE_PATH="." go run ./scripts/clidocgen
505506
cd site
506-
yarn run format:write:only ../docs/cli/*.md ../docs/manifest.json
507+
yarn run format:write:only ../docs/cli.md ../docs/cli/*.md ../docs/manifest.json
507508

508509
docs/admin/audit-logs.md: scripts/auditdocgen/main.go enterprise/audit/table.go
509510
go run scripts/auditdocgen/main.go

‎agent/agent.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,9 @@ func (a *agent) runCoordinator(ctx context.Context, network *tailnet.Conn) error
601601
}
602602
defercoordinator.Close()
603603
a.logger.Info(ctx,"connected to coordination server")
604-
sendNodes,errChan:=tailnet.ServeCoordinator(coordinator,network.UpdateNodes)
604+
sendNodes,errChan:=tailnet.ServeCoordinator(coordinator,func(nodes []*tailnet.Node)error {
605+
returnnetwork.UpdateNodes(nodes,false)
606+
})
605607
network.SetNodeCallback(sendNodes)
606608
select {
607609
case<-ctx.Done():

‎agent/agent_test.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1179,12 +1179,21 @@ func setupAgent(t *testing.T, metadata agentsdk.Metadata, ptyTimeout time.Durati
11791179
coordinator.ServeClient(serverConn,uuid.New(),agentID)
11801180
}()
11811181
sendNode,_:=tailnet.ServeCoordinator(clientConn,func(node []*tailnet.Node)error {
1182-
returnconn.UpdateNodes(node)
1182+
returnconn.UpdateNodes(node,false)
11831183
})
11841184
conn.SetNodeCallback(sendNode)
1185-
return&codersdk.WorkspaceAgentConn{
1185+
agentConn:=&codersdk.WorkspaceAgentConn{
11861186
Conn:conn,
1187-
},c,statsCh,fs
1187+
}
1188+
t.Cleanup(func() {
1189+
_=agentConn.Close()
1190+
})
1191+
ctx,cancel:=context.WithTimeout(context.Background(),testutil.WaitMedium)
1192+
defercancel()
1193+
if!agentConn.AwaitReachable(ctx) {
1194+
t.Fatal("agent not reachable")
1195+
}
1196+
returnagentConn,c,statsCh,fs
11881197
}
11891198

11901199
vardialTestPayload= []byte("dean-was-here123")

‎cli/root.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ import (
1919

2020
"golang.org/x/xerrors"
2121

22+
"cdr.dev/slog"
23+
2224
"github.com/charmbracelet/lipgloss"
2325
"github.com/kirsle/configdir"
2426
"github.com/mattn/go-isatty"
@@ -179,6 +181,21 @@ func Root(subcommands []*cobra.Command) *cobra.Command {
179181
returncmd
180182
}
181183

184+
typecontextKeyint
185+
186+
const (
187+
contextKeyLoggercontextKey=iota
188+
)
189+
190+
funcContextWithLogger(ctx context.Context,l slog.Logger) context.Context {
191+
returncontext.WithValue(ctx,contextKeyLogger,l)
192+
}
193+
194+
funcLoggerFromContext(ctx context.Context) (slog.Logger,bool) {
195+
l,ok:=ctx.Value(contextKeyLogger).(slog.Logger)
196+
returnl,ok
197+
}
198+
182199
// fixUnknownSubcommandError modifies the provided commands so that the
183200
// ones with subcommands output the correct error message when an
184201
// unknown subcommand is invoked.

‎cli/speedtest.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,10 @@ func speedtest() *cobra.Command {
5151
iferr!=nil&&!xerrors.Is(err,cliui.AgentStartError) {
5252
returnxerrors.Errorf("await agent: %w",err)
5353
}
54-
logger:=slog.Make(sloghuman.Sink(cmd.ErrOrStderr()))
54+
logger,ok:=LoggerFromContext(ctx)
55+
if!ok {
56+
logger=slog.Make(sloghuman.Sink(cmd.ErrOrStderr()))
57+
}
5558
ifcliflag.IsSetBool(cmd,varVerbose) {
5659
logger=logger.Leveled(slog.LevelDebug)
5760
}

‎cli/speedtest_test.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ import (
77
"github.com/stretchr/testify/assert"
88
"github.com/stretchr/testify/require"
99

10+
"cdr.dev/slog"
1011
"cdr.dev/slog/sloggers/slogtest"
1112
"github.com/coder/coder/agent"
13+
"github.com/coder/coder/cli"
1214
"github.com/coder/coder/cli/clitest"
1315
"github.com/coder/coder/coderd/coderdtest"
1416
"github.com/coder/coder/codersdk"
@@ -19,6 +21,7 @@ import (
1921

2022
funcTestSpeedtest(t*testing.T) {
2123
t.Parallel()
24+
t.Skip("Flaky test - see https://github.com/coder/coder/issues/6321")
2225
iftesting.Short() {
2326
t.Skip("This test takes a minimum of 5ms per a hardcoded value in Tailscale!")
2427
}
@@ -27,7 +30,7 @@ func TestSpeedtest(t *testing.T) {
2730
agentClient.SetSessionToken(agentToken)
2831
agentCloser:=agent.New(agent.Options{
2932
Client:agentClient,
30-
Logger:slogtest.Make(t,nil).Named("agent"),
33+
Logger:slogtest.Make(t,nil).Named("agent").Leveled(slog.LevelDebug),
3134
})
3235
deferagentCloser.Close()
3336
coderdtest.AwaitWorkspaceAgents(t,client,workspace.ID)
@@ -49,10 +52,12 @@ func TestSpeedtest(t *testing.T) {
4952
clitest.SetupConfig(t,client,root)
5053
pty:=ptytest.New(t)
5154
cmd.SetOut(pty.Output())
55+
cmd.SetErr(pty.Output())
5256

5357
ctx,cancel=context.WithTimeout(context.Background(),testutil.WaitLong)
5458
defercancel()
5559

60+
ctx=cli.ContextWithLogger(ctx,slogtest.Make(t,nil).Named("speedtest").Leveled(slog.LevelDebug))
5661
cmdDone:=tGo(t,func() {
5762
err:=cmd.ExecuteContext(ctx)
5863
assert.NoError(t,err)

‎cli/ssh_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
"golang.org/x/crypto/ssh"
2525
gosshagent"golang.org/x/crypto/ssh/agent"
2626

27+
"cdr.dev/slog"
2728
"cdr.dev/slog/sloggers/slogtest"
2829

2930
"github.com/coder/coder/agent"
@@ -47,6 +48,7 @@ func setupWorkspaceForAgent(t *testing.T, mutate func([]*proto.Agent) []*proto.A
4748
}
4849
}
4950
client:=coderdtest.New(t,&coderdtest.Options{IncludeProvisionerDaemon:true})
51+
client.Logger=slogtest.Make(t,nil).Named("client").Leveled(slog.LevelDebug)
5052
user:=coderdtest.CreateFirstUser(t,client)
5153
agentToken:=uuid.NewString()
5254
version:=coderdtest.CreateTemplateVersion(t,client,user.OrganizationID,&echo.Responses{

‎cli/state.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@ func state() *cobra.Command {
2727
funcstatePull()*cobra.Command {
2828
varbuildNumberint
2929
cmd:=&cobra.Command{
30-
Use:"pull <workspace> [file]",
31-
Args:cobra.MinimumNArgs(1),
30+
Use:"pull <workspace> [file]",
31+
Short:"Pull a Terraform state file from a workspace.",
32+
Args:cobra.MinimumNArgs(1),
3233
RunE:func(cmd*cobra.Command,args []string)error {
3334
client,err:=CreateClient(cmd)
3435
iferr!=nil {
@@ -68,8 +69,9 @@ func statePull() *cobra.Command {
6869
funcstatePush()*cobra.Command {
6970
varbuildNumberint
7071
cmd:=&cobra.Command{
71-
Use:"push <workspace> <file>",
72-
Args:cobra.ExactArgs(2),
72+
Use:"push <workspace> <file>",
73+
Args:cobra.ExactArgs(2),
74+
Short:"Push a Terraform state file to a workspace.",
7375
RunE:func(cmd*cobra.Command,args []string)error {
7476
client,err:=CreateClient(cmd)
7577
iferr!=nil {

‎cli/templatepull_test.go

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ package cli_test
33
import (
44
"bytes"
55
"context"
6-
"io"
6+
"crypto/sha256"
7+
"encoding/hex"
78
"os"
89
"path/filepath"
910
"testing"
1011

1112
"github.com/codeclysm/extract"
1213
"github.com/google/uuid"
13-
"github.com/ory/dockertest/v3/docker/pkg/archive"
1414
"github.com/stretchr/testify/require"
1515

1616
"github.com/coder/coder/cli/clitest"
@@ -20,6 +20,26 @@ import (
2020
"github.com/coder/coder/pty/ptytest"
2121
)
2222

23+
// dirSum calculates a checksum of the files in a directory.
24+
funcdirSum(t*testing.T,dirstring)string {
25+
ents,err:=os.ReadDir(dir)
26+
require.NoError(t,err)
27+
sum:=sha256.New()
28+
for_,e:=rangeents {
29+
path:=filepath.Join(dir,e.Name())
30+
31+
stat,err:=os.Stat(path)
32+
require.NoError(t,err)
33+
34+
byt,err:=os.ReadFile(
35+
path,
36+
)
37+
require.NoError(t,err,"mode: %+v",stat.Mode())
38+
_,_=sum.Write(byt)
39+
}
40+
returnhex.EncodeToString(sum.Sum(nil))
41+
}
42+
2343
funcTestTemplatePull(t*testing.T) {
2444
t.Parallel()
2545

@@ -119,18 +139,10 @@ func TestTemplatePull(t *testing.T) {
119139

120140
require.NoError(t,<-errChan)
121141

122-
expectedTarRd,err:=archive.Tar(expectedDest,archive.Uncompressed)
123-
require.NoError(t,err)
124-
expectedTar,err:=io.ReadAll(expectedTarRd)
125-
require.NoError(t,err)
126-
127-
actualTarRd,err:=archive.Tar(actualDest,archive.Uncompressed)
128-
require.NoError(t,err)
129-
130-
actualTar,err:=io.ReadAll(actualTarRd)
131-
require.NoError(t,err)
132-
133-
require.True(t,bytes.Equal(expectedTar,actualTar),"tar files differ")
142+
require.Equal(t,
143+
dirSum(t,expectedDest),
144+
dirSum(t,actualDest),
145+
)
134146
})
135147

136148
// FolderConflict tests that 'templates pull' fails when a folder with has

‎cli/testdata/coder_state_--help.golden

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ Usage:
66
coder state [command]
77

88
Commands:
9-
pull
10-
push
9+
pullPull a Terraform state file from a workspace.
10+
pushPush a Terraform state file to a workspace.
1111

1212
Flags:
1313
-h, --help help for state

‎cli/testdata/coder_state_pull_--help.golden

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
Pull a Terraform state file from a workspace.
2+
13
Usage:
24
coder state pull <workspace> [file] [flags]
35

‎cli/testdata/coder_state_push_--help.golden

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
Push a Terraform state file to a workspace.
2+
13
Usage:
24
coder state push <workspace> <file> [flags]
35

‎cli/testdata/coder_tokens_list_--help.golden

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,11 @@ Aliases:
77
list, ls
88

99
Flags:
10+
-a, --all Specifies whether all users' tokens will be listed or not (must have
11+
Owner role to see all tokens).
1012
-c, --column strings Columns to display in table output. Available columns: id, last used,
11-
expires at, created at (default [id,last used,expires at,created at])
13+
expires at, created at, owner (default [id,last used,expires
14+
at,created at])
1215
-h, --help help for list
1316
-o, --output string Output format. Available formats: table, json (default "table")
1417

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp