Skip to content

Commit 46a2ff1

Browse files
deansheatherf0ssel
andauthored
feat: allow setting port share protocol (#12383)
Co-authored-by: Garrett Delfosse <garrett@coder.com>
1 parent 23ff807 commit 46a2ff1

25 files changed

+624
-130
lines changed

coderd/apidoc/docs.go

+53-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/apidoc/swagger.json

+36-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/database/dbauthz/dbauthz_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -1608,6 +1608,7 @@ func (s *MethodTestSuite) TestWorkspacePortSharing() {
16081608
AgentName: ps.AgentName,
16091609
Port: ps.Port,
16101610
ShareLevel: ps.ShareLevel,
1611+
Protocol: ps.Protocol,
16111612
}).Asserts(ws, rbac.ActionUpdate).Returns(ps)
16121613
}))
16131614
s.Run("GetWorkspaceAgentPortShare", s.Subtest(func(db database.Store, check *expects) {

coderd/database/dbgen/dbgen.go

+1
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ func WorkspaceAgentPortShare(t testing.TB, db database.Store, orig database.Work
140140
AgentName: takeFirst(orig.AgentName, namesgenerator.GetRandomName(1)),
141141
Port: takeFirst(orig.Port, 8080),
142142
ShareLevel: takeFirst(orig.ShareLevel, database.AppSharingLevelPublic),
143+
Protocol: takeFirst(orig.Protocol, database.PortShareProtocolHttp),
143144
})
144145
require.NoError(t, err, "insert workspace agent")
145146
return ps

coderd/database/dbmem/dbmem.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ func New() database.Store {
8686
UpdatedAt: dbtime.Now(),
8787
})
8888
if err != nil {
89-
panic(fmt.Errorf("failed to create default organization: %w", err))
89+
panic(xerrors.Errorf("failed to create default organization: %w", err))
9090
}
9191
q.defaultProxyDisplayName = "Default"
9292
q.defaultProxyIconURL = "/emojis/1f3e1.png"
@@ -7933,6 +7933,7 @@ func (q *FakeQuerier) UpsertWorkspaceAgentPortShare(_ context.Context, arg datab
79337933
for i, share := range q.workspaceAgentPortShares {
79347934
if share.WorkspaceID == arg.WorkspaceID && share.Port == arg.Port && share.AgentName == arg.AgentName {
79357935
share.ShareLevel = arg.ShareLevel
7936+
share.Protocol = arg.Protocol
79367937
q.workspaceAgentPortShares[i] = share
79377938
return share, nil
79387939
}
@@ -7944,6 +7945,7 @@ func (q *FakeQuerier) UpsertWorkspaceAgentPortShare(_ context.Context, arg datab
79447945
AgentName: arg.AgentName,
79457946
Port: arg.Port,
79467947
ShareLevel: arg.ShareLevel,
7948+
Protocol: arg.Protocol,
79477949
}
79487950
q.workspaceAgentPortShares = append(q.workspaceAgentPortShares, psl)
79497951

coderd/database/dump.sql

+7-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
ALTER TABLE workspace_agent_port_share DROP COLUMN protocol;
2+
3+
DROP TYPE port_share_protocol;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
CREATE TYPE port_share_protocol AS ENUM ('http', 'https');
2+
3+
ALTER TABLE workspace_agent_port_share
4+
ADD COLUMN protocol port_share_protocol NOT NULL DEFAULT 'http'::port_share_protocol;

coderd/database/models.go

+63-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)