MCPcopy Index your code
hub / github.com/coder/coder / WorkspaceProxy

Function WorkspaceProxy

coderd/database/dbgen/dbgen.go:1427–1454  ·  view source on GitHub ↗
(t testing.TB, db database.Store, orig database.WorkspaceProxy)

Source from the content-addressed store, hash-verified

1425}
1426
1427func WorkspaceProxy(t testing.TB, db database.Store, orig database.WorkspaceProxy) (database.WorkspaceProxy, string) {
1428 secret, hashedSecret, err := apikey.GenerateSecret(64)
1429 require.NoError(t, err, "generate secret")
1430
1431 proxy, err := db.InsertWorkspaceProxy(genCtx, database.InsertWorkspaceProxyParams{
1432 ID: takeFirst(orig.ID, uuid.New()),
1433 Name: takeFirst(orig.Name, testutil.GetRandomName(t)),
1434 DisplayName: takeFirst(orig.DisplayName, testutil.GetRandomName(t)),
1435 Icon: takeFirst(orig.Icon, testutil.GetRandomName(t)),
1436 TokenHashedSecret: hashedSecret,
1437 CreatedAt: takeFirst(orig.CreatedAt, dbtime.Now()),
1438 UpdatedAt: takeFirst(orig.UpdatedAt, dbtime.Now()),
1439 DerpEnabled: takeFirst(orig.DerpEnabled, false),
1440 DerpOnly: takeFirst(orig.DerpEnabled, false),
1441 })
1442 require.NoError(t, err, "insert proxy")
1443
1444 // Also set these fields if the caller wants them.
1445 if orig.Url != "" || orig.WildcardHostname != "" {
1446 proxy, err = db.RegisterWorkspaceProxy(genCtx, database.RegisterWorkspaceProxyParams{
1447 Url: orig.Url,
1448 WildcardHostname: orig.WildcardHostname,
1449 ID: proxy.ID,
1450 })
1451 require.NoError(t, err, "update proxy")
1452 }
1453 return proxy, secret
1454}
1455
1456func File(t testing.TB, db database.Store, orig database.File) database.File {
1457 file, err := db.InsertFile(genCtx, database.InsertFileParams{

Callers 8

TestTelemetryFunction · 0.92
TestProxyByHostnameFunction · 0.92
TestGeneratorFunction · 0.92
insertProxyFunction · 0.92

Calls 7

GenerateSecretFunction · 0.92
GetRandomNameFunction · 0.92
NowFunction · 0.92
takeFirstFunction · 0.70
InsertWorkspaceProxyMethod · 0.65
NewMethod · 0.65

Tested by 8

TestTelemetryFunction · 0.74
TestProxyByHostnameFunction · 0.74
TestGeneratorFunction · 0.74
insertProxyFunction · 0.74