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

Skip to content

Commit 76cb7a7

Browse files
committed
feat: return hostname suffix on AgentConnectionInfo
1 parent 7bca3e2 commit 76cb7a7

File tree

7 files changed

+45
-2
lines changed

7 files changed

+45
-2
lines changed

coderd/apidoc/docs.go

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

coderd/apidoc/swagger.json

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

coderd/workspaceagents.go

+2
Original file line numberDiff line numberDiff line change
@@ -882,6 +882,7 @@ func (api *API) workspaceAgentConnection(rw http.ResponseWriter, r *http.Request
882882
DERPMap: api.DERPMap(),
883883
DERPForceWebSockets: api.DeploymentValues.DERP.Config.ForceWebSockets.Value(),
884884
DisableDirectConnections: api.DeploymentValues.DERP.Config.BlockDirect.Value(),
885+
HostnameSuffix: api.DeploymentValues.WorkspaceHostnameSuffix.Value(),
885886
})
886887
}
887888

@@ -903,6 +904,7 @@ func (api *API) workspaceAgentConnectionGeneric(rw http.ResponseWriter, r *http.
903904
DERPMap: api.DERPMap(),
904905
DERPForceWebSockets: api.DeploymentValues.DERP.Config.ForceWebSockets.Value(),
905906
DisableDirectConnections: api.DeploymentValues.DERP.Config.BlockDirect.Value(),
907+
HostnameSuffix: api.DeploymentValues.WorkspaceHostnameSuffix.Value(),
906908
})
907909
}
908910

coderd/workspaceagents_test.go

+31
Original file line numberDiff line numberDiff line change
@@ -2560,3 +2560,34 @@ func requireEqualOrBothNil[T any](t testing.TB, a, b *T) {
25602560
}
25612561
require.Equal(t, a, b)
25622562
}
2563+
2564+
func TestAgentConnectionInfo(t *testing.T) {
2565+
t.Parallel()
2566+
ctx := testutil.Context(t, testutil.WaitShort)
2567+
2568+
dv := coderdtest.DeploymentValues(t)
2569+
dv.WorkspaceHostnameSuffix = "yallah"
2570+
dv.DERP.Config.BlockDirect = true
2571+
dv.DERP.Config.ForceWebSockets = true
2572+
client, db := coderdtest.NewWithDatabase(t, &coderdtest.Options{DeploymentValues: dv})
2573+
user := coderdtest.CreateFirstUser(t, client)
2574+
r := dbfake.WorkspaceBuild(t, db, database.WorkspaceTable{
2575+
OrganizationID: user.OrganizationID,
2576+
OwnerID: user.UserID,
2577+
}).WithAgent().Do()
2578+
2579+
info, err := workspacesdk.New(client).AgentConnectionInfoGeneric(ctx)
2580+
require.NoError(t, err)
2581+
require.Equal(t, "yallah", info.HostnameSuffix)
2582+
require.True(t, info.DisableDirectConnections)
2583+
require.True(t, info.DERPForceWebSockets)
2584+
2585+
ws, err := client.Workspace(ctx, r.Workspace.ID)
2586+
require.NoError(t, err)
2587+
agnt := ws.LatestBuild.Resources[0].Agents[0]
2588+
info, err = workspacesdk.New(client).AgentConnectionInfo(ctx, agnt.ID)
2589+
require.NoError(t, err)
2590+
require.Equal(t, "yallah", info.HostnameSuffix)
2591+
require.True(t, info.DisableDirectConnections)
2592+
require.True(t, info.DERPForceWebSockets)
2593+
}

codersdk/workspacesdk/workspacesdk.go

+1
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ type AgentConnectionInfo struct {
143143
DERPMap *tailcfg.DERPMap `json:"derp_map"`
144144
DERPForceWebSockets bool `json:"derp_force_websockets"`
145145
DisableDirectConnections bool `json:"disable_direct_connections"`
146+
HostnameSuffix string `json:"hostname_suffix"`
146147
}
147148

148149
func (c *Client) AgentConnectionInfoGeneric(ctx context.Context) (AgentConnectionInfo, error) {

docs/reference/api/agents.md

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

docs/reference/api/schemas.md

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

0 commit comments

Comments
 (0)