Skip to content

Commit 64866da

Browse files
committed
Merge remote-tracking branch 'origin/main' into stevenmasley/full_oidc_fake
2 parents 2b0ff9c + f149db6 commit 64866da

File tree

178 files changed

+5441
-4977
lines changed

Some content is hidden

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

178 files changed

+5441
-4977
lines changed

.github/workflows/ci.yaml

Lines changed: 43 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -169,14 +169,35 @@ jobs:
169169
with:
170170
fetch-depth: 1
171171

172-
- name: Install Nix
173-
uses: DeterminateSystems/nix-installer-action@v4
172+
- name: Setup Node
173+
uses: ./.github/actions/setup-node
174+
175+
- name: Setup Go
176+
uses: ./.github/actions/setup-go
174177

175-
- name: Run the Magic Nix Cache
176-
uses: DeterminateSystems/magic-nix-cache-action@v2
178+
- name: Setup sqlc
179+
uses: ./.github/actions/setup-sqlc
180+
181+
- name: go install tools
182+
run: |
183+
go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.30
184+
go install storj.io/drpc/cmd/protoc-gen-go-drpc@v0.0.33
185+
go install golang.org/x/tools/cmd/goimports@latest
186+
go install github.com/mikefarah/yq/v4@v4.30.6
187+
go install github.com/golang/mock/mockgen@v1.6.0
188+
189+
- name: Install Protoc
190+
run: |
191+
mkdir -p /tmp/proto
192+
pushd /tmp/proto
193+
curl -L -o protoc.zip https://github.com/protocolbuffers/protobuf/releases/download/v23.3/protoc-23.3-linux-x86_64.zip
194+
unzip protoc.zip
195+
cp -r ./bin/* /usr/local/bin
196+
cp -r ./include /usr/local/bin/include
197+
popd
177198
178199
- name: make gen
179-
run: "nix-shell --command 'make --output-sync -j -B gen'"
200+
run: "make --output-sync -j -B gen"
180201

181202
- name: Check for unstaged files
182203
run: ./scripts/check_unstaged.sh
@@ -508,15 +529,27 @@ jobs:
508529
- name: Setup Terraform
509530
uses: ./.github/actions/setup-tf
510531

511-
- name: Install Nix
512-
uses: DeterminateSystems/nix-installer-action@v4
532+
- name: go install tools
533+
run: |
534+
go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.30
535+
go install storj.io/drpc/cmd/protoc-gen-go-drpc@v0.0.33
536+
go install golang.org/x/tools/cmd/goimports@latest
537+
go install github.com/mikefarah/yq/v4@v4.30.6
538+
go install github.com/golang/mock/mockgen@v1.6.0
513539
514-
- name: Run the Magic Nix Cache
515-
uses: DeterminateSystems/magic-nix-cache-action@v2
540+
- name: Install Protoc
541+
run: |
542+
mkdir -p /tmp/proto
543+
pushd /tmp/proto
544+
curl -L -o protoc.zip https://github.com/protocolbuffers/protobuf/releases/download/v23.3/protoc-23.3-linux-x86_64.zip
545+
unzip protoc.zip
546+
cp -r ./bin/* /usr/local/bin
547+
cp -r ./include /usr/local/bin/include
548+
popd
516549
517550
- name: Build
518551
run: |
519-
nix-shell --command 'make -B site/out/index.html'
552+
make -B site/out/index.html
520553
521554
- run: pnpm playwright:install
522555
working-directory: site

Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -456,10 +456,10 @@ DB_GEN_FILES := \
456456

457457
# all gen targets should be added here and to gen/mark-fresh
458458
gen: \
459-
coderd/database/dump.sql \
460-
$(DB_GEN_FILES) \
461459
provisionersdk/proto/provisioner.pb.go \
462460
provisionerd/proto/provisionerd.pb.go \
461+
coderd/database/dump.sql \
462+
$(DB_GEN_FILES) \
463463
site/src/api/typesGenerated.ts \
464464
coderd/rbac/object_gen.go \
465465
docs/admin/prometheus.md \
@@ -478,10 +478,10 @@ gen: \
478478
# used during releases so we don't run generation scripts.
479479
gen/mark-fresh:
480480
files="\
481-
coderd/database/dump.sql \
482-
$(DB_GEN_FILES) \
483481
provisionersdk/proto/provisioner.pb.go \
484482
provisionerd/proto/provisionerd.pb.go \
483+
coderd/database/dump.sql \
484+
$(DB_GEN_FILES) \
485485
site/src/api/typesGenerated.ts \
486486
coderd/rbac/object_gen.go \
487487
docs/admin/prometheus.md \

agent/agent.go

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -678,7 +678,7 @@ func (a *agent) run(ctx context.Context) error {
678678
network := a.network
679679
a.closeMutex.Unlock()
680680
if network == nil {
681-
network, err = a.createTailnet(ctx, manifest.AgentID, manifest.DERPMap, manifest.DisableDirectConnections)
681+
network, err = a.createTailnet(ctx, manifest.AgentID, manifest.DERPMap, manifest.DERPForceWebSockets, manifest.DisableDirectConnections)
682682
if err != nil {
683683
return xerrors.Errorf("create tailnet: %w", err)
684684
}
@@ -701,8 +701,10 @@ func (a *agent) run(ctx context.Context) error {
701701
if err != nil {
702702
a.logger.Error(ctx, "update tailnet addresses", slog.Error(err))
703703
}
704-
// Update the DERP map and allow/disallow direct connections.
704+
// Update the DERP map, force WebSocket setting and allow/disallow
705+
// direct connections.
705706
network.SetDERPMap(manifest.DERPMap)
707+
network.SetDERPForceWebSockets(manifest.DERPForceWebSockets)
706708
network.SetBlockEndpoints(manifest.DisableDirectConnections)
707709
}
708710

@@ -756,14 +758,15 @@ func (a *agent) trackConnGoroutine(fn func()) error {
756758
return nil
757759
}
758760

759-
func (a *agent) createTailnet(ctx context.Context, agentID uuid.UUID, derpMap *tailcfg.DERPMap, disableDirectConnections bool) (_ *tailnet.Conn, err error) {
761+
func (a *agent) createTailnet(ctx context.Context, agentID uuid.UUID, derpMap *tailcfg.DERPMap, derpForceWebSockets, disableDirectConnections bool) (_ *tailnet.Conn, err error) {
760762
network, err := tailnet.NewConn(&tailnet.Options{
761-
ID: agentID,
762-
Addresses: a.wireguardAddresses(agentID),
763-
DERPMap: derpMap,
764-
Logger: a.logger.Named("net.tailnet"),
765-
ListenPort: a.tailnetListenPort,
766-
BlockEndpoints: disableDirectConnections,
763+
ID: agentID,
764+
Addresses: a.wireguardAddresses(agentID),
765+
DERPMap: derpMap,
766+
DERPForceWebSockets: derpForceWebSockets,
767+
Logger: a.logger.Named("net.tailnet"),
768+
ListenPort: a.tailnetListenPort,
769+
BlockEndpoints: disableDirectConnections,
767770
})
768771
if err != nil {
769772
return nil, xerrors.Errorf("create tailnet: %w", err)

cli/agent_test.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@ func TestWorkspaceAgent(t *testing.T) {
7575
user := coderdtest.CreateFirstUser(t, client)
7676
version := coderdtest.CreateTemplateVersion(t, client, user.OrganizationID, &echo.Responses{
7777
Parse: echo.ParseComplete,
78-
ProvisionApply: []*proto.Provision_Response{{
79-
Type: &proto.Provision_Response_Complete{
80-
Complete: &proto.Provision_Complete{
78+
ProvisionApply: []*proto.Response{{
79+
Type: &proto.Response_Apply{
80+
Apply: &proto.ApplyComplete{
8181
Resources: []*proto.Resource{{
8282
Name: "somename",
8383
Type: "someinstance",
@@ -127,9 +127,9 @@ func TestWorkspaceAgent(t *testing.T) {
127127
user := coderdtest.CreateFirstUser(t, client)
128128
version := coderdtest.CreateTemplateVersion(t, client, user.OrganizationID, &echo.Responses{
129129
Parse: echo.ParseComplete,
130-
ProvisionApply: []*proto.Provision_Response{{
131-
Type: &proto.Provision_Response_Complete{
132-
Complete: &proto.Provision_Complete{
130+
ProvisionApply: []*proto.Response{{
131+
Type: &proto.Response_Apply{
132+
Apply: &proto.ApplyComplete{
133133
Resources: []*proto.Resource{{
134134
Name: "somename",
135135
Type: "someinstance",
@@ -179,9 +179,9 @@ func TestWorkspaceAgent(t *testing.T) {
179179
user := coderdtest.CreateFirstUser(t, client)
180180
version := coderdtest.CreateTemplateVersion(t, client, user.OrganizationID, &echo.Responses{
181181
Parse: echo.ParseComplete,
182-
ProvisionApply: []*proto.Provision_Response{{
183-
Type: &proto.Provision_Response_Complete{
184-
Complete: &proto.Provision_Complete{
182+
ProvisionApply: []*proto.Response{{
183+
Type: &proto.Response_Apply{
184+
Apply: &proto.ApplyComplete{
185185
Resources: []*proto.Resource{{
186186
Name: "somename",
187187
Type: "someinstance",

cli/configssh_test.go

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,9 @@ func TestConfigSSH(t *testing.T) {
8282
authToken := uuid.NewString()
8383
version := coderdtest.CreateTemplateVersion(t, client, user.OrganizationID, &echo.Responses{
8484
Parse: echo.ParseComplete,
85-
ProvisionPlan: []*proto.Provision_Response{{
86-
Type: &proto.Provision_Response_Complete{
87-
Complete: &proto.Provision_Complete{
85+
ProvisionPlan: []*proto.Response{{
86+
Type: &proto.Response_Plan{
87+
Plan: &proto.PlanComplete{
8888
Resources: []*proto.Resource{{
8989
Name: "example",
9090
Type: "aws_instance",
@@ -720,22 +720,11 @@ func TestConfigSSH_Hostnames(t *testing.T) {
720720
resources = append(resources, resource)
721721
}
722722

723-
provisionResponse := []*proto.Provision_Response{{
724-
Type: &proto.Provision_Response_Complete{
725-
Complete: &proto.Provision_Complete{
726-
Resources: resources,
727-
},
728-
},
729-
}}
730-
731723
client := coderdtest.New(t, &coderdtest.Options{IncludeProvisionerDaemon: true})
732724
user := coderdtest.CreateFirstUser(t, client)
733725
// authToken := uuid.NewString()
734-
version := coderdtest.CreateTemplateVersion(t, client, user.OrganizationID, &echo.Responses{
735-
Parse: echo.ParseComplete,
736-
ProvisionPlan: provisionResponse,
737-
ProvisionApply: provisionResponse,
738-
})
726+
version := coderdtest.CreateTemplateVersion(t, client, user.OrganizationID,
727+
echo.WithResources(resources))
739728
coderdtest.AwaitTemplateVersionJob(t, client, version.ID)
740729
template := coderdtest.CreateTemplate(t, client, user.OrganizationID, version.ID)
741730
workspace := coderdtest.CreateWorkspace(t, client, user.OrganizationID, template.ID)

cli/create_test.go

Lines changed: 29 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,7 @@ func TestCreate(t *testing.T) {
2929
t.Parallel()
3030
client := coderdtest.New(t, &coderdtest.Options{IncludeProvisionerDaemon: true})
3131
user := coderdtest.CreateFirstUser(t, client)
32-
version := coderdtest.CreateTemplateVersion(t, client, user.OrganizationID, &echo.Responses{
33-
Parse: echo.ParseComplete,
34-
ProvisionApply: provisionCompleteWithAgent,
35-
ProvisionPlan: provisionCompleteWithAgent,
36-
})
32+
version := coderdtest.CreateTemplateVersion(t, client, user.OrganizationID, completeWithAgent())
3733
coderdtest.AwaitTemplateVersionJob(t, client, version.ID)
3834
template := coderdtest.CreateTemplate(t, client, user.OrganizationID, version.ID)
3935
args := []string{
@@ -84,11 +80,7 @@ func TestCreate(t *testing.T) {
8480
t.Parallel()
8581
client := coderdtest.New(t, &coderdtest.Options{IncludeProvisionerDaemon: true})
8682
owner := coderdtest.CreateFirstUser(t, client)
87-
version := coderdtest.CreateTemplateVersion(t, client, owner.OrganizationID, &echo.Responses{
88-
Parse: echo.ParseComplete,
89-
ProvisionApply: provisionCompleteWithAgent,
90-
ProvisionPlan: provisionCompleteWithAgent,
91-
})
83+
version := coderdtest.CreateTemplateVersion(t, client, owner.OrganizationID, completeWithAgent())
9284
coderdtest.AwaitTemplateVersionJob(t, client, version.ID)
9385
template := coderdtest.CreateTemplate(t, client, owner.OrganizationID, version.ID)
9486
_, user := coderdtest.CreateAnotherUser(t, client, owner.OrganizationID)
@@ -141,11 +133,7 @@ func TestCreate(t *testing.T) {
141133
t.Parallel()
142134
client := coderdtest.New(t, &coderdtest.Options{IncludeProvisionerDaemon: true})
143135
user := coderdtest.CreateFirstUser(t, client)
144-
version := coderdtest.CreateTemplateVersion(t, client, user.OrganizationID, &echo.Responses{
145-
Parse: echo.ParseComplete,
146-
ProvisionApply: provisionCompleteWithAgent,
147-
ProvisionPlan: provisionCompleteWithAgent,
148-
})
136+
version := coderdtest.CreateTemplateVersion(t, client, user.OrganizationID, completeWithAgent())
149137
coderdtest.AwaitTemplateVersionJob(t, client, version.ID)
150138
template := coderdtest.CreateTemplate(t, client, user.OrganizationID, version.ID, func(ctr *codersdk.CreateTemplateRequest) {
151139
var defaultTTLMillis int64 = 2 * 60 * 60 * 1000 // 2 hours
@@ -240,6 +228,22 @@ func TestCreate(t *testing.T) {
240228
})
241229
}
242230

231+
func prepareEchoResponses(parameters []*proto.RichParameter) *echo.Responses {
232+
return &echo.Responses{
233+
Parse: echo.ParseComplete,
234+
ProvisionPlan: []*proto.Response{
235+
{
236+
Type: &proto.Response_Plan{
237+
Plan: &proto.PlanComplete{
238+
Parameters: parameters,
239+
},
240+
},
241+
},
242+
},
243+
ProvisionApply: echo.ApplyComplete,
244+
}
245+
}
246+
243247
func TestCreateWithRichParameters(t *testing.T) {
244248
t.Parallel()
245249

@@ -258,27 +262,12 @@ func TestCreateWithRichParameters(t *testing.T) {
258262
immutableParameterValue = "4"
259263
)
260264

261-
echoResponses := &echo.Responses{
262-
Parse: echo.ParseComplete,
263-
ProvisionPlan: []*proto.Provision_Response{
264-
{
265-
Type: &proto.Provision_Response_Complete{
266-
Complete: &proto.Provision_Complete{
267-
Parameters: []*proto.RichParameter{
268-
{Name: firstParameterName, Description: firstParameterDescription, Mutable: true},
269-
{Name: secondParameterName, DisplayName: secondParameterDisplayName, Description: secondParameterDescription, Mutable: true},
270-
{Name: immutableParameterName, Description: immutableParameterDescription, Mutable: false},
271-
},
272-
},
273-
},
274-
},
275-
},
276-
ProvisionApply: []*proto.Provision_Response{{
277-
Type: &proto.Provision_Response_Complete{
278-
Complete: &proto.Provision_Complete{},
279-
},
280-
}},
281-
}
265+
echoResponses := prepareEchoResponses([]*proto.RichParameter{
266+
{Name: firstParameterName, Description: firstParameterDescription, Mutable: true},
267+
{Name: secondParameterName, DisplayName: secondParameterDisplayName, Description: secondParameterDescription, Mutable: true},
268+
{Name: immutableParameterName, Description: immutableParameterDescription, Mutable: false},
269+
},
270+
)
282271

283272
t.Run("InputParameters", func(t *testing.T) {
284273
t.Parallel()
@@ -427,28 +416,6 @@ func TestCreateValidateRichParameters(t *testing.T) {
427416
{Name: boolParameterName, Type: "bool", Mutable: true},
428417
}
429418

430-
prepareEchoResponses := func(richParameters []*proto.RichParameter) *echo.Responses {
431-
return &echo.Responses{
432-
Parse: echo.ParseComplete,
433-
ProvisionPlan: []*proto.Provision_Response{
434-
{
435-
Type: &proto.Provision_Response_Complete{
436-
Complete: &proto.Provision_Complete{
437-
Parameters: richParameters,
438-
},
439-
},
440-
},
441-
},
442-
ProvisionApply: []*proto.Provision_Response{
443-
{
444-
Type: &proto.Provision_Response_Complete{
445-
Complete: &proto.Provision_Complete{},
446-
},
447-
},
448-
},
449-
}
450-
}
451-
452419
t.Run("ValidateString", func(t *testing.T) {
453420
t.Parallel()
454421

@@ -626,20 +593,16 @@ func TestCreateWithGitAuth(t *testing.T) {
626593
t.Parallel()
627594
echoResponses := &echo.Responses{
628595
Parse: echo.ParseComplete,
629-
ProvisionPlan: []*proto.Provision_Response{
596+
ProvisionPlan: []*proto.Response{
630597
{
631-
Type: &proto.Provision_Response_Complete{
632-
Complete: &proto.Provision_Complete{
598+
Type: &proto.Response_Plan{
599+
Plan: &proto.PlanComplete{
633600
GitAuthProviders: []string{"github"},
634601
},
635602
},
636603
},
637604
},
638-
ProvisionApply: []*proto.Provision_Response{{
639-
Type: &proto.Provision_Response_Complete{
640-
Complete: &proto.Provision_Complete{},
641-
},
642-
}},
605+
ProvisionApply: echo.ApplyComplete,
643606
}
644607

645608
client := coderdtest.New(t, &coderdtest.Options{

cli/gitssh_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func prepareTestGitSSH(ctx context.Context, t *testing.T) (*codersdk.Client, str
4848
agentToken := uuid.NewString()
4949
version := coderdtest.CreateTemplateVersion(t, client, user.OrganizationID, &echo.Responses{
5050
Parse: echo.ParseComplete,
51-
ProvisionPlan: echo.ProvisionComplete,
51+
ProvisionPlan: echo.PlanComplete,
5252
ProvisionApply: echo.ProvisionApplyWithAgent(agentToken),
5353
})
5454
template := coderdtest.CreateTemplate(t, client, user.OrganizationID, version.ID)

cli/netcheck_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func TestNetcheck(t *testing.T) {
3131
require.NoError(t, json.Unmarshal(b, &report))
3232

3333
assert.True(t, report.Healthy)
34-
require.Len(t, report.Regions, 1+5) // 1 built-in region + 5 STUN regions by default
34+
require.Len(t, report.Regions, 1+1) // 1 built-in region + 1 test-managed STUN region
3535
for _, v := range report.Regions {
3636
require.Len(t, v.NodeReports, len(v.Region.Nodes))
3737
}

cli/portforward_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ func runAgent(t *testing.T, client *codersdk.Client, userID uuid.UUID) codersdk.
302302
agentToken := uuid.NewString()
303303
version := coderdtest.CreateTemplateVersion(t, client, orgID, &echo.Responses{
304304
Parse: echo.ParseComplete,
305-
ProvisionPlan: echo.ProvisionComplete,
305+
ProvisionPlan: echo.PlanComplete,
306306
ProvisionApply: echo.ProvisionApplyWithAgent(agentToken),
307307
})
308308

0 commit comments

Comments
 (0)