mirror of
https://github.com/coder/coder.git
synced 2026-09-22 05:05:20 +08:00
feat: return hostname suffix on AgentConnectionInfo (#17334)
Adds the Hostname Suffix to `AgentConnectionInfo` --- the VPN provider will use it to control the suffix for DNS hostnames. part of: #16828
This commit is contained in:
Generated
+3
@@ -18615,6 +18615,9 @@ const docTemplate = `{
|
||||
},
|
||||
"disable_direct_connections": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"hostname_suffix": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
Generated
+3
@@ -17050,6 +17050,9 @@
|
||||
},
|
||||
"disable_direct_connections": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"hostname_suffix": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -882,6 +882,7 @@ func (api *API) workspaceAgentConnection(rw http.ResponseWriter, r *http.Request
|
||||
DERPMap: api.DERPMap(),
|
||||
DERPForceWebSockets: api.DeploymentValues.DERP.Config.ForceWebSockets.Value(),
|
||||
DisableDirectConnections: api.DeploymentValues.DERP.Config.BlockDirect.Value(),
|
||||
HostnameSuffix: api.DeploymentValues.WorkspaceHostnameSuffix.Value(),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -903,6 +904,7 @@ func (api *API) workspaceAgentConnectionGeneric(rw http.ResponseWriter, r *http.
|
||||
DERPMap: api.DERPMap(),
|
||||
DERPForceWebSockets: api.DeploymentValues.DERP.Config.ForceWebSockets.Value(),
|
||||
DisableDirectConnections: api.DeploymentValues.DERP.Config.BlockDirect.Value(),
|
||||
HostnameSuffix: api.DeploymentValues.WorkspaceHostnameSuffix.Value(),
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -2560,3 +2560,34 @@ func requireEqualOrBothNil[T any](t testing.TB, a, b *T) {
|
||||
}
|
||||
require.Equal(t, a, b)
|
||||
}
|
||||
|
||||
func TestAgentConnectionInfo(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := testutil.Context(t, testutil.WaitShort)
|
||||
|
||||
dv := coderdtest.DeploymentValues(t)
|
||||
dv.WorkspaceHostnameSuffix = "yallah"
|
||||
dv.DERP.Config.BlockDirect = true
|
||||
dv.DERP.Config.ForceWebSockets = true
|
||||
client, db := coderdtest.NewWithDatabase(t, &coderdtest.Options{DeploymentValues: dv})
|
||||
user := coderdtest.CreateFirstUser(t, client)
|
||||
r := dbfake.WorkspaceBuild(t, db, database.WorkspaceTable{
|
||||
OrganizationID: user.OrganizationID,
|
||||
OwnerID: user.UserID,
|
||||
}).WithAgent().Do()
|
||||
|
||||
info, err := workspacesdk.New(client).AgentConnectionInfoGeneric(ctx)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "yallah", info.HostnameSuffix)
|
||||
require.True(t, info.DisableDirectConnections)
|
||||
require.True(t, info.DERPForceWebSockets)
|
||||
|
||||
ws, err := client.Workspace(ctx, r.Workspace.ID)
|
||||
require.NoError(t, err)
|
||||
agnt := ws.LatestBuild.Resources[0].Agents[0]
|
||||
info, err = workspacesdk.New(client).AgentConnectionInfo(ctx, agnt.ID)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "yallah", info.HostnameSuffix)
|
||||
require.True(t, info.DisableDirectConnections)
|
||||
require.True(t, info.DERPForceWebSockets)
|
||||
}
|
||||
|
||||
@@ -143,6 +143,7 @@ type AgentConnectionInfo struct {
|
||||
DERPMap *tailcfg.DERPMap `json:"derp_map"`
|
||||
DERPForceWebSockets bool `json:"derp_force_websockets"`
|
||||
DisableDirectConnections bool `json:"disable_direct_connections"`
|
||||
HostnameSuffix string `json:"hostname_suffix"`
|
||||
}
|
||||
|
||||
func (c *Client) AgentConnectionInfoGeneric(ctx context.Context) (AgentConnectionInfo, error) {
|
||||
|
||||
Generated
+2
-1
@@ -698,7 +698,8 @@ curl -X GET http://coder-server:8080/api/v2/workspaceagents/{workspaceagent}/con
|
||||
}
|
||||
}
|
||||
},
|
||||
"disable_direct_connections": true
|
||||
"disable_direct_connections": true,
|
||||
"hostname_suffix": "string"
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
Generated
+3
-1
@@ -11514,7 +11514,8 @@ None
|
||||
}
|
||||
}
|
||||
},
|
||||
"disable_direct_connections": true
|
||||
"disable_direct_connections": true,
|
||||
"hostname_suffix": "string"
|
||||
}
|
||||
```
|
||||
|
||||
@@ -11525,6 +11526,7 @@ None
|
||||
| `derp_force_websockets` | boolean | false | | |
|
||||
| `derp_map` | [tailcfg.DERPMap](#tailcfgderpmap) | false | | |
|
||||
| `disable_direct_connections` | boolean | false | | |
|
||||
| `hostname_suffix` | string | false | | |
|
||||
|
||||
## wsproxysdk.CryptoKeysResponse
|
||||
|
||||
|
||||
Reference in New Issue
Block a user