Skip to content

Commit 82fd842

Browse files
committed
Merge branch 'main' of https://github.com/coder/coder into bq/refactor-create-template
2 parents 80ac7bf + c6cf719 commit 82fd842

File tree

93 files changed

+565
-207
lines changed

Some content is hidden

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

93 files changed

+565
-207
lines changed

Makefile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,7 @@ gen: \
472472
site/.prettierignore \
473473
site/.eslintignore \
474474
site/e2e/provisionerGenerated.ts \
475+
site/src/theme/icons.json \
475476
examples/examples.gen.json
476477
.PHONY: gen
477478

@@ -495,6 +496,7 @@ gen/mark-fresh:
495496
site/.prettierignore \
496497
site/.eslintignore \
497498
site/e2e/provisionerGenerated.ts \
499+
site/src/theme/icons.json \
498500
examples/examples.gen.json \
499501
"
500502
for file in $$files; do
@@ -538,7 +540,7 @@ provisionerd/proto/provisionerd.pb.go: provisionerd/proto/provisionerd.proto
538540
./provisionerd/proto/provisionerd.proto
539541

540542
site/src/api/typesGenerated.ts: scripts/apitypings/main.go $(shell find ./codersdk $(FIND_EXCLUSIONS) -type f -name '*.go')
541-
go run scripts/apitypings/main.go > site/src/api/typesGenerated.ts
543+
go run ./scripts/apitypings/ > site/src/api/typesGenerated.ts
542544
cd site
543545
pnpm run format:types ./src/api/typesGenerated.ts
544546

@@ -547,6 +549,10 @@ site/e2e/provisionerGenerated.ts: provisionerd/proto/provisionerd.pb.go provisio
547549
../scripts/pnpm_install.sh
548550
pnpm run gen:provisioner
549551

552+
site/src/theme/icons.json: $(wildcard site/static/icon/*)
553+
go run ./scripts/gensite/ -icons $@
554+
pnpm run format:write:only $@
555+
550556
examples/examples.gen.json: scripts/examplegen/main.go examples/examples.go $(shell find ./examples/templates)
551557
go run ./scripts/examplegen/main.go > examples/examples.gen.json
552558

coderd/apidoc/docs.go

Lines changed: 4 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/apidoc/swagger.json

Lines changed: 4 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/tailnet.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,10 @@ func (s *ServerTailnet) watchAgentUpdates() {
229229

230230
err := s.conn.UpdateNodes(nodes, false)
231231
if err != nil {
232+
if xerrors.Is(err, tailnet.ErrConnClosed) {
233+
s.logger.Warn(context.Background(), "tailnet conn closed, exiting watchAgentUpdates", slog.Error(err))
234+
return
235+
}
232236
s.logger.Error(context.Background(), "update node in server tailnet", slog.Error(err))
233237
return
234238
}

coderd/users.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1167,12 +1167,12 @@ func convertUsers(users []database.User, organizationIDsByUserID map[uuid.UUID][
11671167

11681168
func userOrganizationIDs(ctx context.Context, api *API, user database.User) ([]uuid.UUID, error) {
11691169
organizationIDsByMemberIDsRows, err := api.Database.GetOrganizationIDsByMemberIDs(ctx, []uuid.UUID{user.ID})
1170-
if errors.Is(err, sql.ErrNoRows) {
1171-
return []uuid.UUID{}, xerrors.Errorf("user %q must be a member of at least one organization", user.Email)
1172-
}
11731170
if err != nil {
11741171
return []uuid.UUID{}, err
11751172
}
1173+
if len(organizationIDsByMemberIDsRows) == 0 {
1174+
return []uuid.UUID{}, xerrors.Errorf("user %q must be a member of at least one organization", user.Email)
1175+
}
11761176
member := organizationIDsByMemberIDsRows[0]
11771177
return member.OrganizationIDs, nil
11781178
}

codersdk/deployment.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1985,6 +1985,9 @@ const (
19851985
// Deployment health page
19861986
ExperimentDeploymentHealthPage Experiment = "deployment_health_page"
19871987

1988+
// ExperimentDashboardTheme mutates the dashboard to use a new, dark color scheme.
1989+
ExperimentDashboardTheme Experiment = "dashboard_theme"
1990+
19881991
// Add new experiments here!
19891992
// ExperimentExample Experiment = "example"
19901993
)

docs/api/schemas.md

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

enterprise/tailnet/pgcoord.go

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"fmt"
88
"net"
99
"net/http"
10+
"net/netip"
1011
"strings"
1112
"sync"
1213
"time"
@@ -143,10 +144,27 @@ func NewPGCoord(ctx context.Context, logger slog.Logger, ps pubsub.Pubsub, store
143144
return c, nil
144145
}
145146

147+
// This is copied from codersdk because importing it here would cause an import
148+
// cycle. This is just temporary until wsconncache is phased out.
149+
var legacyAgentIP = netip.MustParseAddr("fd7a:115c:a1e0:49d6:b259:b7ac:b1b2:48f4")
150+
146151
func (c *pgCoord) ServeMultiAgent(id uuid.UUID) agpl.MultiAgentConn {
147152
ma := (&agpl.MultiAgent{
148-
ID: id,
149-
AgentIsLegacyFunc: func(agentID uuid.UUID) bool { return true },
153+
ID: id,
154+
AgentIsLegacyFunc: func(agentID uuid.UUID) bool {
155+
if n := c.Node(agentID); n == nil {
156+
// If we don't have the node at all assume it's legacy for
157+
// safety.
158+
return true
159+
} else if len(n.Addresses) > 0 && n.Addresses[0].Addr() == legacyAgentIP {
160+
// An agent is determined to be "legacy" if it's first IP is the
161+
// legacy IP. Agents with only the legacy IP aren't compatible
162+
// with single_tailnet and must be routed through wsconncache.
163+
return true
164+
} else {
165+
return false
166+
}
167+
},
150168
OnSubscribe: func(enq agpl.Queue, agent uuid.UUID) (*agpl.Node, error) {
151169
err := c.addSubscription(enq, agent)
152170
return c.Node(agent), err

scripts/gensite/generateIconList.go

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
package main
2+
3+
import (
4+
"encoding/json"
5+
"fmt"
6+
"os"
7+
)
8+
9+
func generateIconList(path string) int {
10+
if path == "" {
11+
return 0 // skip
12+
}
13+
14+
files, err := os.ReadDir("site/static/icon/")
15+
if err != nil {
16+
_, _ = fmt.Println("failed to read site/static/icon/ directory")
17+
_, _ = fmt.Println("err:", err.Error())
18+
return 71 // OSERR
19+
}
20+
21+
icons := make([]string, len(files))
22+
i := 0
23+
for _, file := range files {
24+
if !file.Type().IsRegular() {
25+
continue
26+
}
27+
28+
icons[i] = file.Name()
29+
i++
30+
}
31+
icons = icons[:i]
32+
33+
outputFile, err := os.Create(path)
34+
if err != nil {
35+
_, _ = fmt.Println("failed to create file")
36+
_, _ = fmt.Println("err:", err.Error())
37+
return 73 // CANTCREAT
38+
}
39+
defer outputFile.Close()
40+
41+
iconsJSON, err := json.Marshal(icons)
42+
if err != nil {
43+
_, _ = fmt.Println("failed to serialize JSON")
44+
_, _ = fmt.Println("err:", err.Error())
45+
return 70 // SOFTWARE
46+
}
47+
48+
written, err := outputFile.Write(iconsJSON)
49+
if err != nil || written != len(iconsJSON) {
50+
_, _ = fmt.Println("failed to write JSON")
51+
if err != nil {
52+
_, _ = fmt.Println("err:", err.Error())
53+
}
54+
return 74 // IOERR
55+
}
56+
57+
_, _ = fmt.Println(green.Sprintf("==>"), path)
58+
59+
return 0
60+
}

scripts/gensite/main.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package main
2+
3+
import (
4+
"flag"
5+
"os"
6+
7+
"github.com/fatih/color"
8+
)
9+
10+
var green = color.New(color.FgGreen).Add(color.Bold)
11+
12+
func main() {
13+
var iconsPath string
14+
flag.StringVar(&iconsPath, "icons", "", "the path to place icons.json at")
15+
flag.Parse()
16+
17+
status := generateIconList(iconsPath)
18+
os.Exit(status)
19+
}

site/.storybook/preview.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { withRouter } from "storybook-addon-react-router-v6";
88
import { HelmetProvider } from "react-helmet-async";
99
import { dark } from "theme";
1010
import "theme/globalFonts";
11-
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
11+
import { QueryClient, QueryClientProvider } from "react-query";
1212

1313
export const decorators = [
1414
(Story) => (

site/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646
"@mui/styles": "5.14.0",
4747
"@mui/system": "5.14.0",
4848
"@mui/utils": "5.14.11",
49-
"@tanstack/react-query": "4.35.3",
5049
"@vitejs/plugin-react": "4.1.0",
5150
"@xstate/inspect": "0.8.0",
5251
"@xstate/react": "3.2.1",
@@ -55,6 +54,7 @@
5554
"canvas": "2.11.0",
5655
"chart.js": "4.4.0",
5756
"chartjs-adapter-date-fns": "3.0.0",
57+
"chartjs-plugin-annotation": "3.0.1",
5858
"chroma-js": "2.4.2",
5959
"color-convert": "2.0.1",
6060
"cron-parser": "4.9.0",
@@ -78,6 +78,7 @@
7878
"react-dom": "18.2.0",
7979
"react-helmet-async": "1.3.0",
8080
"react-markdown": "8.0.7",
81+
"react-query": "npm:@tanstack/react-query@4.35.3",
8182
"react-router-dom": "6.16.0",
8283
"react-syntax-highlighter": "15.5.0",
8384
"react-use": "17.4.0",

site/pnpm-lock.yaml

Lines changed: 14 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

site/src/App.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import CssBaseline from "@mui/material/CssBaseline";
2-
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
2+
import { QueryClient, QueryClientProvider } from "react-query";
33
import { AuthProvider } from "components/AuthProvider/AuthProvider";
44
import { FC, PropsWithChildren } from "react";
55
import { HelmetProvider } from "react-helmet-async";

site/src/api/queries/appearance.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { QueryClient } from "@tanstack/react-query";
1+
import { QueryClient } from "react-query";
22
import * as API from "api/api";
33
import { AppearanceConfig } from "api/typesGenerated";
44
import { getMetadataAsJSON } from "utils/metadata";

site/src/api/queries/entitlements.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { QueryClient } from "@tanstack/react-query";
1+
import { QueryClient } from "react-query";
22
import * as API from "api/api";
33
import { Entitlements } from "api/typesGenerated";
44
import { getMetadataAsJSON } from "utils/metadata";

site/src/api/queries/groups.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { QueryClient } from "@tanstack/react-query";
1+
import { QueryClient } from "react-query";
22
import * as API from "api/api";
33
import { checkAuthorization } from "api/api";
44
import {

site/src/api/queries/settings.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {
33
type UserQuietHoursScheduleResponse,
44
type UpdateUserQuietHoursScheduleRequest,
55
} from "api/typesGenerated";
6-
import { type QueryClient, type QueryOptions } from "@tanstack/react-query";
6+
import { type QueryClient, type QueryOptions } from "react-query";
77

88
export const userQuietHoursScheduleKey = (userId: string) => [
99
"settings",

site/src/api/queries/sshKeys.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { QueryClient } from "@tanstack/react-query";
1+
import { QueryClient } from "react-query";
22
import * as API from "api/api";
33
import { GitSSHKey } from "api/typesGenerated";
44

site/src/api/queries/templates.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
CreateTemplateRequest,
99
ProvisionerJob,
1010
} from "api/typesGenerated";
11-
import { type QueryClient, type QueryOptions } from "@tanstack/react-query";
11+
import { type QueryClient, type QueryOptions } from "react-query";
1212
import { delay } from "utils/delay";
1313

1414
export const templateByNameKey = (orgId: string, name: string) => [

site/src/api/queries/users.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { QueryClient, QueryOptions } from "@tanstack/react-query";
1+
import { QueryClient, QueryOptions } from "react-query";
22
import * as API from "api/api";
33
import {
44
GetUsersResponse,

site/src/api/queries/workspace.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as API from "api/api";
22
import { type Workspace } from "api/typesGenerated";
3-
import { type QueryOptions } from "@tanstack/react-query";
3+
import { type QueryOptions } from "react-query";
44

55
export const workspaceByOwnerAndNameKey = (owner: string, name: string) => [
66
"workspace",

site/src/api/queries/workspaceBuilds.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { UseInfiniteQueryOptions } from "@tanstack/react-query";
1+
import { UseInfiniteQueryOptions } from "react-query";
22
import * as API from "api/api";
33
import { WorkspaceBuild, WorkspaceBuildsRequest } from "api/typesGenerated";
44

site/src/api/typesGenerated.ts

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)