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

Skip to content

Commit 567cfa4

Browse files
committed
Merge remote-tracking branch 'origin/main' into authzquerier_layer
2 parents a4c4489 + b359dbb commit 567cfa4

File tree

101 files changed

+1005
-313
lines changed

Some content is hidden

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

101 files changed

+1005
-313
lines changed

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,8 @@ test-postgres-docker:
610610
-c max_connections=1000 \
611611
-c fsync=off \
612612
-c synchronous_commit=off \
613-
-c full_page_writes=off
613+
-c full_page_writes=off \
614+
-c log_statement=all
614615
while ! pg_isready -h 127.0.0.1
615616
do
616617
echo "$(date) - waiting for database to start"

agent/agent.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,10 +268,13 @@ func (a *agent) run(ctx context.Context) error {
268268

269269
scriptDone := make(chan error, 1)
270270
scriptStart := time.Now()
271-
go func() {
271+
err := a.trackConnGoroutine(func() {
272272
defer close(scriptDone)
273273
scriptDone <- a.runStartupScript(ctx, metadata.StartupScript)
274-
}()
274+
})
275+
if err != nil {
276+
return xerrors.Errorf("track startup script: %w", err)
277+
}
275278
go func() {
276279
var timeout <-chan time.Time
277280
// If timeout is zero, an older version of the coder

agent/agent_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ func TestAgent_TCPLocalForwarding(t *testing.T) {
305305
}
306306
}()
307307

308-
cmd := setupSSHCommand(t, []string{"-L", fmt.Sprintf("%d:127.0.0.1:%d", randomPort, remotePort)}, []string{"sleep", "10"})
308+
cmd := setupSSHCommand(t, []string{"-L", fmt.Sprintf("%d:127.0.0.1:%d", randomPort, remotePort)}, []string{"sleep", "5"})
309309
err = cmd.Start()
310310
require.NoError(t, err)
311311

@@ -372,7 +372,7 @@ func TestAgent_TCPRemoteForwarding(t *testing.T) {
372372
}
373373
}()
374374

375-
cmd := setupSSHCommand(t, []string{"-R", fmt.Sprintf("127.0.0.1:%d:127.0.0.1:%d", randomPort, localPort)}, []string{"sleep", "10"})
375+
cmd := setupSSHCommand(t, []string{"-R", fmt.Sprintf("127.0.0.1:%d:127.0.0.1:%d", randomPort, localPort)}, []string{"sleep", "5"})
376376
err = cmd.Start()
377377
require.NoError(t, err)
378378

@@ -437,7 +437,7 @@ func TestAgent_UnixLocalForwarding(t *testing.T) {
437437
}
438438
}()
439439

440-
cmd := setupSSHCommand(t, []string{"-L", fmt.Sprintf("%s:%s", localSocketPath, remoteSocketPath)}, []string{"sleep", "10"})
440+
cmd := setupSSHCommand(t, []string{"-L", fmt.Sprintf("%s:%s", localSocketPath, remoteSocketPath)}, []string{"sleep", "5"})
441441
err = cmd.Start()
442442
require.NoError(t, err)
443443

@@ -495,7 +495,7 @@ func TestAgent_UnixRemoteForwarding(t *testing.T) {
495495
}
496496
}()
497497

498-
cmd := setupSSHCommand(t, []string{"-R", fmt.Sprintf("%s:%s", remoteSocketPath, localSocketPath)}, []string{"sleep", "10"})
498+
cmd := setupSSHCommand(t, []string{"-R", fmt.Sprintf("%s:%s", remoteSocketPath, localSocketPath)}, []string{"sleep", "5"})
499499
err = cmd.Start()
500500
require.NoError(t, err)
501501

@@ -703,7 +703,7 @@ func TestAgent_Lifecycle(t *testing.T) {
703703
t.Parallel()
704704

705705
_, client, _, _ := setupAgent(t, agentsdk.Metadata{
706-
StartupScript: "sleep 10",
706+
StartupScript: "sleep 5",
707707
StartupScriptTimeout: time.Nanosecond,
708708
}, 0)
709709

cli/deployment/config.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ func newConfig() *codersdk.DeploymentConfig {
486486
},
487487
MaxTokenLifetime: &codersdk.DeploymentConfigField[time.Duration]{
488488
Name: "Max Token Lifetime",
489-
Usage: "The maximum lifetime duration for any user creating a token.",
489+
Usage: "The maximum lifetime duration users can specify when creating an API token.",
490490
Flag: "max-token-lifetime",
491491
Default: 24 * 30 * time.Hour,
492492
},
@@ -538,6 +538,18 @@ func newConfig() *codersdk.DeploymentConfig {
538538
Flag: "disable-path-apps",
539539
Default: false,
540540
},
541+
SessionDuration: &codersdk.DeploymentConfigField[time.Duration]{
542+
Name: "Session Duration",
543+
Usage: "The token expiry duration for browser sessions. Sessions may last longer if they are actively making requests, but this functionality can be disabled via --disable-session-expiry-refresh.",
544+
Flag: "session-duration",
545+
Default: 24 * time.Hour,
546+
},
547+
DisableSessionExpiryRefresh: &codersdk.DeploymentConfigField[bool]{
548+
Name: "Disable Session Expiry Refresh",
549+
Usage: "Disable automatic session expiry bumping due to activity. This forces all sessions to become invalid after the session expiry duration has been reached.",
550+
Flag: "disable-session-expiry-refresh",
551+
Default: false,
552+
},
541553
}
542554
}
543555

cli/root_test.go

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ var updateGoldenFiles = flag.Bool("update", false, "update .golden files")
3131
//nolint:tparallel,paralleltest // These test sets env vars.
3232
func TestCommandHelp(t *testing.T) {
3333
commonEnv := map[string]string{
34-
"CODER_CONFIG_DIR": "/tmp/coder-cli-test-config",
34+
"HOME": "~",
35+
"CODER_CONFIG_DIR": "~/.config/coderv2",
3536
}
3637

3738
type testCase struct {
@@ -48,7 +49,7 @@ func TestCommandHelp(t *testing.T) {
4849
name: "coder server --help",
4950
cmd: []string{"server", "--help"},
5051
env: map[string]string{
51-
"CODER_CACHE_DIRECTORY": "/tmp/coder-cli-test-cache",
52+
"CODER_CACHE_DIRECTORY": "~/.cache/coder",
5253
},
5354
},
5455
{
@@ -104,19 +105,27 @@ ExtractCommandPathsLoop:
104105

105106
ctx, _ := testutil.Context(t)
106107

108+
tmpwd := "/"
109+
if runtime.GOOS == "windows" {
110+
tmpwd = "C:\\"
111+
}
112+
err := os.Chdir(tmpwd)
107113
var buf bytes.Buffer
108114
root, _ := clitest.New(t, tt.cmd...)
109115
root.SetOut(&buf)
110-
err := root.ExecuteContext(ctx)
116+
assert.NoError(t, err)
117+
err = root.ExecuteContext(ctx)
118+
err2 := os.Chdir(wd)
111119
require.NoError(t, err)
120+
require.NoError(t, err2)
112121

113122
got := buf.Bytes()
114123
// Remove CRLF newlines (Windows).
115124
got = bytes.ReplaceAll(got, []byte{'\r', '\n'}, []byte{'\n'})
116125

117126
// The `coder templates create --help` command prints the path
118127
// to the working directory (--directory flag default value).
119-
got = bytes.ReplaceAll(got, []byte(wd), []byte("/tmp/coder-cli-test-workdir"))
128+
got = bytes.ReplaceAll(got, []byte(fmt.Sprintf("%q", tmpwd)), []byte("\"[current directory]\""))
120129

121130
gf := filepath.Join("testdata", strings.Replace(tt.name, " ", "_", -1)+".golden")
122131
if *updateGoldenFiles {

cli/ssh.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ func uploadGPGKeys(ctx context.Context, sshClient *gossh.Client) error {
458458
//
459459
// Note: we sleep after killing the agent because it doesn't always die
460460
// immediately.
461-
agentSocketBytes, err := runRemoteSSH(sshClient, nil, `
461+
agentSocketBytes, err := runRemoteSSH(sshClient, nil, `sh -c '
462462
set -eux
463463
agent_socket=$(gpgconf --list-dir agent-socket)
464464
echo "$agent_socket"
@@ -470,7 +470,7 @@ if [ -S "$agent_socket" ]; then
470470
fi
471471
472472
test ! -S "$agent_socket"
473-
`)
473+
'`)
474474
agentSocket := strings.TrimSpace(string(agentSocketBytes))
475475
if err != nil {
476476
return xerrors.Errorf("check if agent socket is running (check if %q exists): %w", agentSocket, err)

cli/testdata/coder_--help.golden

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ Workspace Commands:
4848

4949
Flags:
5050
--global-config coder Path to the global coder config directory.
51-
Consumes $CODER_CONFIG_DIR (default "/tmp/coder-cli-test-config")
51+
Consumes $CODER_CONFIG_DIR (default "~/.config/coderv2")
5252
--header stringArray HTTP headers added to all requests. Provide as "Key=Value".
5353
Consumes $CODER_HEADER
5454
-h, --help help for coder

cli/testdata/coder_agent_--help.golden

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Flags:
1313

1414
Global Flags:
1515
--global-config coder Path to the global coder config directory.
16-
Consumes $CODER_CONFIG_DIR (default "/tmp/coder-cli-test-config")
16+
Consumes $CODER_CONFIG_DIR (default "~/.config/coderv2")
1717
--header stringArray HTTP headers added to all requests. Provide as "Key=Value".
1818
Consumes $CODER_HEADER
1919
--no-feature-warning Suppress warnings about unlicensed features.

cli/testdata/coder_config-ssh_--help.golden

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Flags:
2727

2828
Global Flags:
2929
--global-config coder Path to the global coder config directory.
30-
Consumes $CODER_CONFIG_DIR (default "/tmp/coder-cli-test-config")
30+
Consumes $CODER_CONFIG_DIR (default "~/.config/coderv2")
3131
--header stringArray HTTP headers added to all requests. Provide as "Key=Value".
3232
Consumes $CODER_HEADER
3333
--no-feature-warning Suppress warnings about unlicensed features.

cli/testdata/coder_create_--help.golden

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Flags:
2323

2424
Global Flags:
2525
--global-config coder Path to the global coder config directory.
26-
Consumes $CODER_CONFIG_DIR (default "/tmp/coder-cli-test-config")
26+
Consumes $CODER_CONFIG_DIR (default "~/.config/coderv2")
2727
--header stringArray HTTP headers added to all requests. Provide as "Key=Value".
2828
Consumes $CODER_HEADER
2929
--no-feature-warning Suppress warnings about unlicensed features.

cli/testdata/coder_delete_--help.golden

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Flags:
1414

1515
Global Flags:
1616
--global-config coder Path to the global coder config directory.
17-
Consumes $CODER_CONFIG_DIR (default "/tmp/coder-cli-test-config")
17+
Consumes $CODER_CONFIG_DIR (default "~/.config/coderv2")
1818
--header stringArray HTTP headers added to all requests. Provide as "Key=Value".
1919
Consumes $CODER_HEADER
2020
--no-feature-warning Suppress warnings about unlicensed features.

cli/testdata/coder_dotfiles_--help.golden

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Flags:
1717

1818
Global Flags:
1919
--global-config coder Path to the global coder config directory.
20-
Consumes $CODER_CONFIG_DIR (default "/tmp/coder-cli-test-config")
20+
Consumes $CODER_CONFIG_DIR (default "~/.config/coderv2")
2121
--header stringArray HTTP headers added to all requests. Provide as "Key=Value".
2222
Consumes $CODER_HEADER
2323
--no-feature-warning Suppress warnings about unlicensed features.

cli/testdata/coder_list_--help.golden

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Flags:
1616

1717
Global Flags:
1818
--global-config coder Path to the global coder config directory.
19-
Consumes $CODER_CONFIG_DIR (default "/tmp/coder-cli-test-config")
19+
Consumes $CODER_CONFIG_DIR (default "~/.config/coderv2")
2020
--header stringArray HTTP headers added to all requests. Provide as "Key=Value".
2121
Consumes $CODER_HEADER
2222
--no-feature-warning Suppress warnings about unlicensed features.

cli/testdata/coder_login_--help.golden

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Flags:
2020

2121
Global Flags:
2222
--global-config coder Path to the global coder config directory.
23-
Consumes $CODER_CONFIG_DIR (default "/tmp/coder-cli-test-config")
23+
Consumes $CODER_CONFIG_DIR (default "~/.config/coderv2")
2424
--header stringArray HTTP headers added to all requests. Provide as "Key=Value".
2525
Consumes $CODER_HEADER
2626
--no-feature-warning Suppress warnings about unlicensed features.

cli/testdata/coder_logout_--help.golden

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Flags:
99

1010
Global Flags:
1111
--global-config coder Path to the global coder config directory.
12-
Consumes $CODER_CONFIG_DIR (default "/tmp/coder-cli-test-config")
12+
Consumes $CODER_CONFIG_DIR (default "~/.config/coderv2")
1313
--header stringArray HTTP headers added to all requests. Provide as "Key=Value".
1414
Consumes $CODER_HEADER
1515
--no-feature-warning Suppress warnings about unlicensed features.

cli/testdata/coder_port-forward_--help.golden

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Flags:
3535

3636
Global Flags:
3737
--global-config coder Path to the global coder config directory.
38-
Consumes $CODER_CONFIG_DIR (default "/tmp/coder-cli-test-config")
38+
Consumes $CODER_CONFIG_DIR (default "~/.config/coderv2")
3939
--header stringArray HTTP headers added to all requests. Provide as "Key=Value".
4040
Consumes $CODER_HEADER
4141
--no-feature-warning Suppress warnings about unlicensed features.

cli/testdata/coder_publickey_--help.golden

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Flags:
1414

1515
Global Flags:
1616
--global-config coder Path to the global coder config directory.
17-
Consumes $CODER_CONFIG_DIR (default "/tmp/coder-cli-test-config")
17+
Consumes $CODER_CONFIG_DIR (default "~/.config/coderv2")
1818
--header stringArray HTTP headers added to all requests. Provide as "Key=Value".
1919
Consumes $CODER_HEADER
2020
--no-feature-warning Suppress warnings about unlicensed features.

cli/testdata/coder_rename_--help.golden

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Flags:
99

1010
Global Flags:
1111
--global-config coder Path to the global coder config directory.
12-
Consumes $CODER_CONFIG_DIR (default "/tmp/coder-cli-test-config")
12+
Consumes $CODER_CONFIG_DIR (default "~/.config/coderv2")
1313
--header stringArray HTTP headers added to all requests. Provide as "Key=Value".
1414
Consumes $CODER_HEADER
1515
--no-feature-warning Suppress warnings about unlicensed features.

cli/testdata/coder_reset-password_--help.golden

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Flags:
1010

1111
Global Flags:
1212
--global-config coder Path to the global coder config directory.
13-
Consumes $CODER_CONFIG_DIR (default "/tmp/coder-cli-test-config")
13+
Consumes $CODER_CONFIG_DIR (default "~/.config/coderv2")
1414
--header stringArray HTTP headers added to all requests. Provide as "Key=Value".
1515
Consumes $CODER_HEADER
1616
--no-feature-warning Suppress warnings about unlicensed features.

cli/testdata/coder_restart_--help.golden

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Flags:
99

1010
Global Flags:
1111
--global-config coder Path to the global coder config directory.
12-
Consumes $CODER_CONFIG_DIR (default "/tmp/coder-cli-test-config")
12+
Consumes $CODER_CONFIG_DIR (default "~/.config/coderv2")
1313
--header stringArray HTTP headers added to all requests. Provide as "Key=Value".
1414
Consumes $CODER_HEADER
1515
--no-feature-warning Suppress warnings about unlicensed features.

cli/testdata/coder_scaletest_--help.golden

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Flags:
1414

1515
Global Flags:
1616
--global-config coder Path to the global coder config directory.
17-
Consumes $CODER_CONFIG_DIR (default "/tmp/coder-cli-test-config")
17+
Consumes $CODER_CONFIG_DIR (default "~/.config/coderv2")
1818
--header stringArray HTTP headers added to all requests. Provide as "Key=Value".
1919
Consumes $CODER_HEADER
2020
--no-feature-warning Suppress warnings about unlicensed features.

cli/testdata/coder_scaletest_cleanup_--help.golden

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Flags:
1616

1717
Global Flags:
1818
--global-config coder Path to the global coder config directory.
19-
Consumes $CODER_CONFIG_DIR (default "/tmp/coder-cli-test-config")
19+
Consumes $CODER_CONFIG_DIR (default "~/.config/coderv2")
2020
--header stringArray HTTP headers added to all requests. Provide as "Key=Value".
2121
Consumes $CODER_HEADER
2222
--no-feature-warning Suppress warnings about unlicensed features.

cli/testdata/coder_scaletest_create-workspaces_--help.golden

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ Flags:
115115

116116
Global Flags:
117117
--global-config coder Path to the global coder config directory.
118-
Consumes $CODER_CONFIG_DIR (default "/tmp/coder-cli-test-config")
118+
Consumes $CODER_CONFIG_DIR (default "~/.config/coderv2")
119119
--header stringArray HTTP headers added to all requests. Provide as "Key=Value".
120120
Consumes $CODER_HEADER
121121
--no-feature-warning Suppress warnings about unlicensed features.

cli/testdata/coder_schedule_--help.golden

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Flags:
1616

1717
Global Flags:
1818
--global-config coder Path to the global coder config directory.
19-
Consumes $CODER_CONFIG_DIR (default "/tmp/coder-cli-test-config")
19+
Consumes $CODER_CONFIG_DIR (default "~/.config/coderv2")
2020
--header stringArray HTTP headers added to all requests. Provide as "Key=Value".
2121
Consumes $CODER_HEADER
2222
--no-feature-warning Suppress warnings about unlicensed features.

cli/testdata/coder_schedule_override-stop_--help.golden

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Flags:
1414

1515
Global Flags:
1616
--global-config coder Path to the global coder config directory.
17-
Consumes $CODER_CONFIG_DIR (default "/tmp/coder-cli-test-config")
17+
Consumes $CODER_CONFIG_DIR (default "~/.config/coderv2")
1818
--header stringArray HTTP headers added to all requests. Provide as "Key=Value".
1919
Consumes $CODER_HEADER
2020
--no-feature-warning Suppress warnings about unlicensed features.

cli/testdata/coder_schedule_show_--help.golden

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Flags:
1212

1313
Global Flags:
1414
--global-config coder Path to the global coder config directory.
15-
Consumes $CODER_CONFIG_DIR (default "/tmp/coder-cli-test-config")
15+
Consumes $CODER_CONFIG_DIR (default "~/.config/coderv2")
1616
--header stringArray HTTP headers added to all requests. Provide as "Key=Value".
1717
Consumes $CODER_HEADER
1818
--no-feature-warning Suppress warnings about unlicensed features.

cli/testdata/coder_schedule_start_--help.golden

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Flags:
2121

2222
Global Flags:
2323
--global-config coder Path to the global coder config directory.
24-
Consumes $CODER_CONFIG_DIR (default "/tmp/coder-cli-test-config")
24+
Consumes $CODER_CONFIG_DIR (default "~/.config/coderv2")
2525
--header stringArray HTTP headers added to all requests. Provide as "Key=Value".
2626
Consumes $CODER_HEADER
2727
--no-feature-warning Suppress warnings about unlicensed features.

cli/testdata/coder_schedule_stop_--help.golden

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Flags:
2222

2323
Global Flags:
2424
--global-config coder Path to the global coder config directory.
25-
Consumes $CODER_CONFIG_DIR (default "/tmp/coder-cli-test-config")
25+
Consumes $CODER_CONFIG_DIR (default "~/.config/coderv2")
2626
--header stringArray HTTP headers added to all requests. Provide as "Key=Value".
2727
Consumes $CODER_HEADER
2828
--no-feature-warning Suppress warnings about unlicensed features.

0 commit comments

Comments
 (0)