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

Skip to content

Commit 03d9e9a

Browse files
committed
Merge branch 'main' into 3522-enterprise-1
2 parents 05b6a98 + 8e9cbdd commit 03d9e9a

File tree

146 files changed

+4169
-2498
lines changed

Some content is hidden

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

146 files changed

+4169
-2498
lines changed

.github/workflows/codeql.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
name: "CodeQL"
22

3+
permissions:
4+
security-events: write
5+
36
on:
47
push:
58
branches: ["main"]

.github/workflows/packages.yaml

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,22 @@ jobs:
1515
run: |
1616
Invoke-WebRequest https://aka.ms/wingetcreate/latest -OutFile wingetcreate.exe
1717
18-
# The package version is the same as the tag minus the leading "v".
19-
- name: Calculate package version
20-
id: version
21-
run: |
22-
$version = $env:CODER_VERSION -replace "^v", ""
23-
echo "::set-output name=version::$version"
24-
2518
- name: Submit updated manifest to winget-pkgs
2619
run: |
2720
$release_assets = gh release view --repo coder/coder "$env:CODER_VERSION" --json assets | `
2821
ConvertFrom-Json
29-
22+
# Get the installer URL from the release assets.
3023
$installer_url = $release_assets.assets | `
3124
Where-Object name -Match ".*_windows_amd64_installer.exe$" | `
3225
Select -ExpandProperty url
3326
3427
echo "Installer URL: $installer_url"
3528
29+
# The package version is the same as the tag minus the leading "v".
30+
$version = $env:CODER_VERSION.Trim('v')
31+
32+
echo "Package version: $version"
33+
3634
# The URL "|X64" suffix forces the architecture as it cannot be
3735
# sniffed properly from the URL. wingetcreate checks both the URL and
3836
# binary magic bytes for the architecture and they need to both match,
@@ -44,7 +42,7 @@ jobs:
4442
# submission.
4543
.\wingetcreate.exe update Coder.Coder `
4644
--submit `
47-
--version "${{ steps.version.outputs.version }}" `
45+
--version "${version}" `
4846
--urls "${installer_url}|X64" `
4947
--token "${{ secrets.CDRCI_GITHUB_TOKEN }}"
5048

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ site/**/*.typegen.ts
2323
site/build-storybook.log
2424
site/coverage/
2525
site/storybook-static/
26-
site/test-results/
26+
site/test-results/*
27+
site/e2e/test-results/*
28+
site/e2e/storageState.json
29+
site/playwright-report/*
2730

2831
# Make target for updating golden files.
2932
cli/testdata/.gen-golden

.prettierignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@ site/**/*.typegen.ts
2626
site/build-storybook.log
2727
site/coverage/
2828
site/storybook-static/
29-
site/test-results/
29+
site/test-results/*
30+
site/e2e/test-results/*
31+
site/e2e/storageState.json
32+
site/playwright-report/*
3033

3134
# Make target for updating golden files.
3235
cli/testdata/.gen-golden

.swaggo

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,8 @@
11
// Replace all NullTime with string
22
replace github.com/coder/coder/codersdk.NullTime string
3+
// Prevent swaggo from rendering enums for time.Duration
4+
replace time.Duration int64
5+
// Do not expose "echo" provider
6+
replace github.com/coder/coder/codersdk.ProvisionerType string
7+
// Do not render netip.Addr
8+
replace netip.Addr string

README.md

Lines changed: 12 additions & 12 deletions
Large diffs are not rendered by default.

agent/agent.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,18 @@ func (a *agent) createTailnet(ctx context.Context, derpMap *tailcfg.DERPMap) (_
304304
if err != nil {
305305
return
306306
}
307-
go a.sshServer.HandleConn(conn)
307+
closed := make(chan struct{})
308+
_ = a.trackConnGoroutine(func() {
309+
select {
310+
case <-network.Closed():
311+
case <-closed:
312+
}
313+
_ = conn.Close()
314+
})
315+
_ = a.trackConnGoroutine(func() {
316+
defer close(closed)
317+
a.sshServer.HandleConn(conn)
318+
})
308319
}
309320
}); err != nil {
310321
return nil, err

cli/root.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ func Core() []*cobra.Command {
9797
update(),
9898
users(),
9999
versionCmd(),
100-
vscodeipcCmd(),
100+
vscodeSSH(),
101101
workspaceAgent(),
102102
}
103103
}

cli/scaletest.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"strconv"
1010
"strings"
1111
"sync"
12+
"syscall"
1213
"time"
1314

1415
"github.com/google/uuid"
@@ -185,7 +186,9 @@ func (o *scaleTestOutput) write(res harness.Results, stdout io.Writer) error {
185186
// Sync the file to disk if it's a file.
186187
if s, ok := w.(interface{ Sync() error }); ok {
187188
err := s.Sync()
188-
if err != nil {
189+
// On Linux, EINVAL is returned when calling fsync on /dev/stdout. We
190+
// can safely ignore this error.
191+
if err != nil && !xerrors.Is(err, syscall.EINVAL) {
189192
return xerrors.Errorf("flush output file: %w", err)
190193
}
191194
}

cli/server.go

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,20 @@ func Server(vip *viper.Viper, newAPI func(context.Context, *coderd.Options) (*co
226226
}
227227
defer httpListener.Close()
228228

229+
listenAddrStr := httpListener.Addr().String()
230+
// For some reason if 0.0.0.0:x is provided as the http address,
231+
// httpListener.Addr().String() likes to return it as an ipv6
232+
// address (i.e. [::]:x). If the input ip is 0.0.0.0, try to
233+
// coerce the output back to ipv4 to make it less confusing.
234+
if strings.Contains(cfg.HTTPAddress.Value, "0.0.0.0") {
235+
listenAddrStr = strings.ReplaceAll(listenAddrStr, "[::]", "0.0.0.0")
236+
}
237+
238+
// We want to print out the address the user supplied, not the
239+
// loopback device.
240+
cmd.Println("Started HTTP listener at", (&url.URL{Scheme: "http", Host: listenAddrStr}).String())
241+
242+
// Set the http URL we want to use when connecting to ourselves.
229243
tcpAddr, tcpAddrValid := httpListener.Addr().(*net.TCPAddr)
230244
if !tcpAddrValid {
231245
return xerrors.Errorf("invalid TCP address type %T", httpListener.Addr())
@@ -237,7 +251,6 @@ func Server(vip *viper.Viper, newAPI func(context.Context, *coderd.Options) (*co
237251
Scheme: "http",
238252
Host: tcpAddr.String(),
239253
}
240-
cmd.Println("Started HTTP listener at " + httpURL.String())
241254
}
242255

243256
var (
@@ -269,6 +282,22 @@ func Server(vip *viper.Viper, newAPI func(context.Context, *coderd.Options) (*co
269282
httpsListener = tls.NewListener(httpsListenerInner, tlsConfig)
270283
defer httpsListener.Close()
271284

285+
listenAddrStr := httpsListener.Addr().String()
286+
// For some reason if 0.0.0.0:x is provided as the https
287+
// address, httpsListener.Addr().String() likes to return it as
288+
// an ipv6 address (i.e. [::]:x). If the input ip is 0.0.0.0,
289+
// try to coerce the output back to ipv4 to make it less
290+
// confusing.
291+
if strings.Contains(cfg.HTTPAddress.Value, "0.0.0.0") {
292+
listenAddrStr = strings.ReplaceAll(listenAddrStr, "[::]", "0.0.0.0")
293+
}
294+
295+
// We want to print out the address the user supplied, not the
296+
// loopback device.
297+
cmd.Println("Started TLS/HTTPS listener at", (&url.URL{Scheme: "https", Host: listenAddrStr}).String())
298+
299+
// Set the https URL we want to use when connecting to
300+
// ourselves.
272301
tcpAddr, tcpAddrValid := httpsListener.Addr().(*net.TCPAddr)
273302
if !tcpAddrValid {
274303
return xerrors.Errorf("invalid TCP address type %T", httpsListener.Addr())
@@ -280,7 +309,6 @@ func Server(vip *viper.Viper, newAPI func(context.Context, *coderd.Options) (*co
280309
Scheme: "https",
281310
Host: tcpAddr.String(),
282311
}
283-
cmd.Println("Started TLS/HTTPS listener at " + httpsURL.String())
284312
}
285313

286314
// Sanity check that at least one listener was started.

cli/server_test.go

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -674,6 +674,58 @@ func TestServer(t *testing.T) {
674674
}
675675
})
676676

677+
t.Run("CanListenUnspecifiedv4", func(t *testing.T) {
678+
t.Parallel()
679+
ctx, cancelFunc := context.WithCancel(context.Background())
680+
defer cancelFunc()
681+
682+
root, _ := clitest.New(t,
683+
"server",
684+
"--in-memory",
685+
"--http-address", "0.0.0.0:0",
686+
"--access-url", "http://example.com",
687+
)
688+
689+
pty := ptytest.New(t)
690+
root.SetOutput(pty.Output())
691+
root.SetErr(pty.Output())
692+
errC := make(chan error, 1)
693+
go func() {
694+
errC <- root.ExecuteContext(ctx)
695+
}()
696+
697+
pty.ExpectMatch("Started HTTP listener at http://0.0.0.0:")
698+
699+
cancelFunc()
700+
require.NoError(t, <-errC)
701+
})
702+
703+
t.Run("CanListenUnspecifiedv6", func(t *testing.T) {
704+
t.Parallel()
705+
ctx, cancelFunc := context.WithCancel(context.Background())
706+
defer cancelFunc()
707+
708+
root, _ := clitest.New(t,
709+
"server",
710+
"--in-memory",
711+
"--http-address", "[::]:0",
712+
"--access-url", "http://example.com",
713+
)
714+
715+
pty := ptytest.New(t)
716+
root.SetOutput(pty.Output())
717+
root.SetErr(pty.Output())
718+
errC := make(chan error, 1)
719+
go func() {
720+
errC <- root.ExecuteContext(ctx)
721+
}()
722+
723+
pty.ExpectMatch("Started HTTP listener at http://[::]:")
724+
725+
cancelFunc()
726+
require.NoError(t, <-errC)
727+
})
728+
677729
t.Run("NoAddress", func(t *testing.T) {
678730
t.Parallel()
679731
ctx, cancelFunc := context.WithCancel(context.Background())

cli/ssh.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ func getWorkspaceAndAgent(ctx context.Context, cmd *cobra.Command, client *coder
256256
)
257257
if shuffle {
258258
res, err := client.Workspaces(ctx, codersdk.WorkspaceFilter{
259-
Owner: codersdk.Me,
259+
Owner: userID,
260260
})
261261
if err != nil {
262262
return codersdk.Workspace{}, codersdk.WorkspaceAgent{}, err

cli/vscodeipc.go

Lines changed: 0 additions & 88 deletions
This file was deleted.

0 commit comments

Comments
 (0)