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

Method PrimaryRegion

coderd/workspaceproxies.go:20–49  ·  view source on GitHub ↗

PrimaryRegion exposes the user facing values of a workspace proxy to be used by a user.

(ctx context.Context)

Source from the content-addressed store, hash-verified

18// PrimaryRegion exposes the user facing values of a workspace proxy to
19// be used by a user.
20func (api *API) PrimaryRegion(ctx context.Context) (codersdk.Region, error) {
21 deploymentIDStr, err := api.Database.GetDeploymentID(ctx)
22 if xerrors.Is(err, sql.ErrNoRows) {
23 // This shouldn't happen but it's pretty easy to avoid this causing
24 // issues by falling back to a nil UUID.
25 deploymentIDStr = uuid.Nil.String()
26 } else if err != nil {
27 return codersdk.Region{}, xerrors.Errorf("get deployment ID: %w", err)
28 }
29 deploymentID, err := uuid.Parse(deploymentIDStr)
30 if err != nil {
31 // This also shouldn't happen but we fallback to nil UUID.
32 deploymentID = uuid.Nil
33 }
34
35 proxy, err := api.Database.GetDefaultProxyConfig(ctx)
36 if err != nil {
37 return codersdk.Region{}, xerrors.Errorf("get default proxy config: %w", err)
38 }
39
40 return codersdk.Region{
41 ID: deploymentID,
42 Name: "primary",
43 DisplayName: proxy.DisplayName,
44 IconURL: proxy.IconURL,
45 Healthy: true,
46 PathAppURL: api.AccessURL.String(),
47 WildcardHostname: appurl.SubdomainAppHost(api.AppHostname, api.AccessURL),
48 }, nil
49}
50
51// PrimaryWorkspaceProxy returns the primary workspace proxy for the site.
52func (api *API) PrimaryWorkspaceProxy(ctx context.Context) (database.WorkspaceProxy, error) {

Callers 2

PrimaryWorkspaceProxyMethod · 0.95
regionsMethod · 0.95

Calls 7

SubdomainAppHostFunction · 0.92
GetDeploymentIDMethod · 0.65
ParseMethod · 0.65
GetDefaultProxyConfigMethod · 0.65
IsMethod · 0.45
StringMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected