Skip to content

Commit 98b6ecb

Browse files
committed
t
1 parent 502c768 commit 98b6ecb

File tree

8 files changed

+259
-235
lines changed

8 files changed

+259
-235
lines changed

coderd/database/dbfake/dbfake.go

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515

1616
"github.com/google/uuid"
1717
"github.com/lib/pq"
18+
"golang.org/x/exp/constraints"
1819
"golang.org/x/exp/maps"
1920
"golang.org/x/exp/slices"
2021
"golang.org/x/xerrors"
@@ -605,8 +606,8 @@ func uniqueSortedUUIDs(uuids []uuid.UUID) []uuid.UUID {
605606
for id := range set {
606607
unique = append(unique, id)
607608
}
608-
slices.SortFunc(unique, func(a, b uuid.UUID) bool {
609-
return a.String() < b.String()
609+
slices.SortFunc(unique, func(a, b uuid.UUID) int {
610+
return orderingAscend(a, b)
610611
})
611612
return unique
612613
}
@@ -3126,9 +3127,8 @@ func (q *FakeQuerier) GetWorkspaceBuildsByWorkspaceID(_ context.Context,
31263127
}
31273128

31283129
// Order by build_number
3129-
slices.SortFunc(history, func(a, b database.WorkspaceBuild) bool {
3130-
// use greater than since we want descending order
3131-
return a.BuildNumber > b.BuildNumber
3130+
slices.SortFunc(history, func(a, b database.WorkspaceBuild) int {
3131+
return orderingDescend(a.BuildNumber, b.BuildNumber)
31323132
})
31333133

31343134
if params.AfterID != uuid.Nil {
@@ -3527,8 +3527,14 @@ func (q *FakeQuerier) InsertAuditLog(_ context.Context, arg database.InsertAudit
35273527
alog := database.AuditLog(arg)
35283528

35293529
q.auditLogs = append(q.auditLogs, alog)
3530-
slices.SortFunc(q.auditLogs, func(a, b database.AuditLog) bool {
3531-
return a.Time.Before(b.Time)
3530+
slices.SortFunc(q.auditLogs, func(a, b database.AuditLog) int {
3531+
if a.Time.Before(b.Time) {
3532+
return -1
3533+
} else if a.Time.Equal(b.Time) {
3534+
return 0
3535+
} else {
3536+
return 1
3537+
}
35323538
})
35333539

35343540
return alog, nil
@@ -5859,3 +5865,17 @@ func (q *FakeQuerier) GetAuthorizedUsers(ctx context.Context, arg database.GetUs
58595865
}
58605866
return filteredUsers, nil
58615867
}
5868+
5869+
func orderingAscend[E constraints.Ordered](a, b E) int {
5870+
if a < b {
5871+
return -1
5872+
} else if a == b {
5873+
return 0
5874+
} else {
5875+
return 1
5876+
}
5877+
}
5878+
5879+
func orderingDescend[E constraints.Ordered](a, b E) int {
5880+
return -orderingAscend[E](a, b)
5881+
}

coderd/healthcheck/derp.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ func (r *DERPReport) Run(ctx context.Context, opts *DERPReportOptions) {
118118
mu.Unlock()
119119
}
120120
nc := &netcheck.Client{
121-
PortMapper: portmapper.NewClient(tslogger.WithPrefix(ncLogf, "portmap: "), nil),
121+
PortMapper: portmapper.NewClient(tslogger.WithPrefix(ncLogf, "portmap: "), nil, nil, nil),
122122
Logf: tslogger.WithPrefix(ncLogf, "netcheck: "),
123123
}
124124
ncReport, netcheckErr := nc.GetReport(ctx, opts.DERPMap)

enterprise/tailnet/pgcoord.go

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1351,8 +1351,8 @@ func (c *pgCoord) htmlDebug(ctx context.Context) (agpl.HTMLDebug, error) {
13511351
Node: conn.Node,
13521352
})
13531353
}
1354-
slices.SortFunc(htmlAgent.Connections, func(a, b *agpl.HTMLClient) bool {
1355-
return a.Name < b.Name
1354+
slices.SortFunc(htmlAgent.Connections, func(a, b *agpl.HTMLClient) int {
1355+
return nameOrdering(a.Name, b.Name)
13561356
})
13571357

13581358
data.Agents = append(data.Agents, htmlAgent)
@@ -1362,8 +1362,8 @@ func (c *pgCoord) htmlDebug(ctx context.Context) (agpl.HTMLDebug, error) {
13621362
Node: agent.Node,
13631363
})
13641364
}
1365-
slices.SortFunc(data.Agents, func(a, b *agpl.HTMLAgent) bool {
1366-
return a.Name < b.Name
1365+
slices.SortFunc(data.Agents, func(a, b *agpl.HTMLAgent) int {
1366+
return nameOrdering(a.Name, b.Name)
13671367
})
13681368

13691369
for agentID, conns := range clients {
@@ -1389,15 +1389,25 @@ func (c *pgCoord) htmlDebug(ctx context.Context) (agpl.HTMLDebug, error) {
13891389
Node: conn.Node,
13901390
})
13911391
}
1392-
slices.SortFunc(agent.Connections, func(a, b *agpl.HTMLClient) bool {
1393-
return a.Name < b.Name
1392+
slices.SortFunc(agent.Connections, func(a, b *agpl.HTMLClient) int {
1393+
return nameOrdering(a.Name, b.Name)
13941394
})
13951395

13961396
data.MissingAgents = append(data.MissingAgents, agent)
13971397
}
1398-
slices.SortFunc(data.MissingAgents, func(a, b *agpl.HTMLAgent) bool {
1399-
return a.Name < b.Name
1398+
slices.SortFunc(data.MissingAgents, func(a, b *agpl.HTMLAgent) int {
1399+
return nameOrdering(a.Name, b.Name)
14001400
})
14011401

14021402
return data, nil
14031403
}
1404+
1405+
func nameOrdering(a, b string) int {
1406+
if a < b {
1407+
return -1
1408+
} else if a == b {
1409+
return 0
1410+
} else {
1411+
return 1
1412+
}
1413+
}

go.mod

Lines changed: 45 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ replace github.com/dlclark/regexp2 => github.com/dlclark/regexp2 v1.7.0
3636

3737
// There are a few minor changes we make to Tailscale that we're slowly upstreaming. Compare here:
3838
// https://github.com/tailscale/tailscale/compare/main...coder:tailscale:main
39-
replace tailscale.com => github.com/coder/tailscale v0.0.0-20230731105344-d1b7f8087191
39+
replace tailscale.com => github.com/coder/tailscale v1.1.1-0.20230803194128-b940c19ca61b
4040

4141
// Use our tempfork of gvisor that includes a fix for TCP connection stalls:
4242
// https://github.com/coder/coder/issues/7388
@@ -117,6 +117,7 @@ require (
117117
github.com/golang/mock v1.6.0
118118
github.com/google/go-github/v43 v43.0.1-0.20220414155304-00e42332e405
119119
github.com/google/uuid v1.3.0
120+
github.com/hashicorp/go-multierror v1.1.1
120121
github.com/hashicorp/go-reap v0.0.0-20170704170343-bf58d8a43e7b
121122
github.com/hashicorp/go-version v1.6.0
122123
github.com/hashicorp/golang-lru/v2 v2.0.1
@@ -130,7 +131,7 @@ require (
130131
github.com/jmoiron/sqlx v1.3.5
131132
github.com/justinas/nosurf v1.1.1
132133
github.com/kirsle/configdir v0.0.0-20170128060238-e45d2f54772f
133-
github.com/klauspost/compress v1.16.3
134+
github.com/klauspost/compress v1.16.5
134135
github.com/lib/pq v1.10.6
135136
github.com/mattn/go-isatty v0.0.19
136137
github.com/mitchellh/go-wordwrap v1.0.1
@@ -144,7 +145,7 @@ require (
144145
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e
145146
github.com/pkg/sftp v1.13.6-0.20221018182125-7da137aa03f0
146147
github.com/prometheus/client_golang v1.16.0
147-
github.com/prometheus/client_model v0.3.0
148+
github.com/prometheus/client_model v0.4.0
148149
github.com/prometheus/common v0.42.0
149150
github.com/quasilyte/go-ruleguard/dsl v0.3.21
150151
github.com/robfig/cron/v3 v3.0.1
@@ -168,9 +169,9 @@ require (
168169
go.opentelemetry.io/otel/trace v1.16.0
169170
go.uber.org/atomic v1.11.0
170171
go.uber.org/goleak v1.2.1
171-
go4.org/netipx v0.0.0-20220725152314-7e7bdc8411bf
172+
go4.org/netipx v0.0.0-20230728180743-ad4cb58a6516
172173
golang.org/x/crypto v0.11.0
173-
golang.org/x/exp v0.0.0-20230315142452-642cacee5cc0
174+
golang.org/x/exp v0.0.0-20230725093048-515e97ebf090
174175
golang.org/x/mod v0.12.0
175176
golang.org/x/net v0.12.0
176177
golang.org/x/oauth2 v0.10.0
@@ -185,23 +186,22 @@ require (
185186
google.golang.org/protobuf v1.31.0
186187
gopkg.in/natefinch/lumberjack.v2 v2.2.1
187188
gopkg.in/yaml.v3 v3.0.1
188-
gvisor.dev/gvisor v0.0.0-20221203005347-703fd9b7fbc0
189+
gvisor.dev/gvisor v0.0.0-20230504175454-7b0a1988a28f
189190
nhooyr.io/websocket v1.8.7
190191
storj.io/drpc v0.0.33-0.20230420154621-9716137f6037
191-
tailscale.com v1.32.3
192192
)
193193

194194
require (
195195
cloud.google.com/go/compute v1.23.0 // indirect
196196
cloud.google.com/go/logging v1.7.0 // indirect
197197
cloud.google.com/go/longrunning v0.5.1 // indirect
198-
filippo.io/edwards25519 v1.0.0-rc.1 // indirect
198+
filippo.io/edwards25519 v1.0.0 // indirect
199199
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect
200200
github.com/KyleBanks/depth v1.2.1 // indirect
201201
github.com/Microsoft/go-winio v0.6.1 // indirect
202202
github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 // indirect
203203
github.com/OneOfOne/xxhash v1.2.8 // indirect
204-
github.com/ProtonMail/go-crypto v0.0.0-20230217124315-7d5c6f04bbb8 // indirect
204+
github.com/ProtonMail/go-crypto v0.0.0-20230426101702-58e86b294756 // indirect
205205
github.com/agext/levenshtein v1.2.3 // indirect
206206
github.com/agnivade/levenshtein v1.1.1 // indirect
207207
github.com/akutz/memconn v0.1.0 // indirect
@@ -225,8 +225,8 @@ require (
225225
github.com/containerd/continuity v0.4.1 // indirect
226226
github.com/coreos/go-iptables v0.6.0 // indirect
227227
github.com/dlclark/regexp2 v1.10.0 // indirect
228-
github.com/docker/cli v20.10.17+incompatible // indirect
229-
github.com/docker/docker v23.0.3+incompatible // indirect
228+
github.com/docker/cli v23.0.5+incompatible // indirect
229+
github.com/docker/docker v23.0.5+incompatible // indirect
230230
github.com/docker/go-connections v0.4.0 // indirect
231231
github.com/docker/go-units v0.5.0 // indirect
232232
github.com/elastic/go-windows v1.0.0 // indirect
@@ -236,10 +236,10 @@ require (
236236
github.com/gin-gonic/gin v1.9.1 // indirect
237237
github.com/go-logr/stdr v1.2.2 // indirect
238238
github.com/go-ole/go-ole v1.2.6 // indirect
239-
github.com/go-openapi/jsonpointer v0.19.5 // indirect
240-
github.com/go-openapi/jsonreference v0.20.0 // indirect
239+
github.com/go-openapi/jsonpointer v0.19.6 // indirect
240+
github.com/go-openapi/jsonreference v0.20.2 // indirect
241241
github.com/go-openapi/spec v0.20.6 // indirect
242-
github.com/go-openapi/swag v0.19.15 // indirect
242+
github.com/go-openapi/swag v0.22.3 // indirect
243243
github.com/go-playground/locales v0.14.1 // indirect
244244
github.com/go-playground/universal-translator v0.18.1 // indirect
245245
github.com/go-test/deep v1.0.8 // indirect
@@ -265,22 +265,21 @@ require (
265265
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
266266
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 // indirect
267267
github.com/hashicorp/go-hclog v1.2.1 // indirect
268-
github.com/hashicorp/go-multierror v1.1.1
269268
github.com/hashicorp/go-uuid v1.0.3 // indirect
270269
github.com/hashicorp/hcl v1.0.0 // indirect
271270
github.com/hashicorp/hcl/v2 v2.17.0 // indirect
272271
github.com/hashicorp/logutils v1.0.0 // indirect
273272
github.com/hashicorp/terraform-plugin-go v0.12.0 // indirect
274273
github.com/hashicorp/terraform-plugin-log v0.7.0 // indirect
275274
github.com/hashicorp/terraform-plugin-sdk/v2 v2.20.0 // indirect
276-
github.com/hdevalence/ed25519consensus v0.0.0-20220222234857-c00d1f31bab3 // indirect
275+
github.com/hdevalence/ed25519consensus v0.1.0 // indirect
277276
github.com/illarion/gonotify v1.0.1 // indirect
278-
github.com/imdario/mergo v0.3.13 // indirect
279-
github.com/insomniacslk/dhcp v0.0.0-20221215072855-de60144f33f8 // indirect
277+
github.com/imdario/mergo v0.3.15 // indirect
278+
github.com/insomniacslk/dhcp v0.0.0-20230407062729-974c6f05fe16 // indirect
280279
github.com/joeshaw/multierror v0.0.0-20140124173710-69b34d4ec901 // indirect
281280
github.com/josharian/intern v1.0.0 // indirect
282281
github.com/josharian/native v1.1.1-0.20230202152459-5c7d0dd6ab86 // indirect
283-
github.com/jsimonetti/rtnetlink v1.1.2-0.20220408201609-d380b505068b // indirect
282+
github.com/jsimonetti/rtnetlink v1.3.2 // indirect
284283
github.com/juju/errors v1.0.0 // indirect
285284
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
286285
github.com/kortschak/wol v0.0.0-20200729010619-da482cc4850a // indirect
@@ -292,13 +291,13 @@ require (
292291
github.com/mattn/go-localereader v0.0.1 // indirect
293292
github.com/mattn/go-runewidth v0.0.15 // indirect
294293
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
295-
github.com/mdlayher/genetlink v1.2.0 // indirect
296-
github.com/mdlayher/netlink v1.6.2 // indirect
294+
github.com/mdlayher/genetlink v1.3.2 // indirect
295+
github.com/mdlayher/netlink v1.7.2 // indirect
297296
github.com/mdlayher/sdnotify v1.0.0 // indirect
298-
github.com/mdlayher/socket v0.2.3 // indirect
297+
github.com/mdlayher/socket v0.4.1 // indirect
299298
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b // indirect
300299
github.com/microcosm-cc/bluemonday v1.0.23 // indirect
301-
github.com/miekg/dns v1.1.45 // indirect
300+
github.com/miekg/dns v1.1.55 // indirect
302301
github.com/mitchellh/copystructure v1.2.0 // indirect
303302
github.com/mitchellh/go-ps v1.0.0 // indirect
304303
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
@@ -326,18 +325,18 @@ require (
326325
github.com/swaggo/files/v2 v2.0.0 // indirect
327326
github.com/tadvi/systray v0.0.0-20190226123456-11a2b8fa57af // indirect
328327
github.com/tailscale/certstore v0.1.1-0.20220316223106-78d6e1c49d8d // indirect
329-
github.com/tailscale/golang-x-crypto v0.0.0-20221102133106-bc99ab8c2d17 // indirect
328+
github.com/tailscale/golang-x-crypto v0.0.0-20230713185742-f0b76a10a08e // indirect
330329
github.com/tailscale/goupnp v1.0.1-0.20210804011211-c64d0f06ea05 // indirect
331330
github.com/tailscale/netlink v1.1.1-0.20211101221916-cabfb018fe85 // indirect
332-
github.com/tailscale/wireguard-go v0.0.0-20221219190806-4fa124729667 // indirect
331+
github.com/tailscale/wireguard-go v0.0.0-20230710185534-bb2c8f22eccf // indirect
333332
github.com/tchap/go-patricia/v2 v2.3.1 // indirect
334333
github.com/tcnksm/go-httpstat v0.2.0 // indirect
335334
github.com/tdewolff/parse/v2 v2.6.6 // indirect
336335
github.com/tdewolff/test v1.0.9 // indirect
337-
github.com/u-root/uio v0.0.0-20221213070652-c3537552635f // indirect
336+
github.com/u-root/uio v0.0.0-20230305220412-3e8cd9d6bf63 // indirect
338337
github.com/ulikunitz/xz v0.5.11 // indirect
339338
github.com/vishvananda/netlink v1.2.1-beta.2 // indirect
340-
github.com/vishvananda/netns v0.0.0-20211101163701-50045581ed74 // indirect
339+
github.com/vishvananda/netns v0.0.4 // indirect
341340
github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect
342341
github.com/vmihailenco/msgpack/v4 v4.3.12 // indirect
343342
github.com/vmihailenco/tagparser v0.1.1 // indirect
@@ -355,7 +354,7 @@ require (
355354
go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.16.0 // indirect
356355
go.opentelemetry.io/otel/metric v1.16.0 // indirect
357356
go.opentelemetry.io/proto/otlp v0.19.0 // indirect
358-
go4.org/mem v0.0.0-20210711025021-927187094b94 // indirect
357+
go4.org/mem v0.0.0-20220726221520-4f986261bf13 // indirect
359358
golang.org/x/text v0.11.0
360359
golang.org/x/time v0.3.0 // indirect
361360
golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2 // indirect
@@ -370,7 +369,25 @@ require (
370369
inet.af/peercred v0.0.0-20210906144145-0893ea02156a // indirect
371370
)
372371

372+
require tailscale.com v0.0.0-00010101000000-000000000000
373+
373374
require (
375+
github.com/aws/aws-sdk-go-v2 v1.18.0 // indirect
376+
github.com/aws/aws-sdk-go-v2/config v1.18.22 // indirect
377+
github.com/aws/aws-sdk-go-v2/credentials v1.13.21 // indirect
378+
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.3 // indirect
379+
github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.33 // indirect
380+
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.27 // indirect
381+
github.com/aws/aws-sdk-go-v2/internal/ini v1.3.34 // indirect
382+
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.27 // indirect
383+
github.com/aws/aws-sdk-go-v2/service/ssm v1.36.3 // indirect
384+
github.com/aws/aws-sdk-go-v2/service/sso v1.12.9 // indirect
385+
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.9 // indirect
386+
github.com/aws/aws-sdk-go-v2/service/sts v1.18.10 // indirect
387+
github.com/aws/smithy-go v1.13.5 // indirect
374388
github.com/go-ini/ini v1.67.0 // indirect
389+
github.com/google/nftables v0.1.1-0.20230115205135-9aa6fdf5a28c // indirect
375390
github.com/gorilla/mux v1.8.0 // indirect
391+
github.com/jmespath/go-jmespath v0.4.0 // indirect
392+
github.com/pierrec/lz4/v4 v4.1.17 // indirect
376393
)

0 commit comments

Comments
 (0)