Skip to content

Commit 7dee309

Browse files
committed
Fix moon feature flag panic
1 parent 163bbff commit 7dee309

File tree

1 file changed

+24
-19
lines changed

1 file changed

+24
-19
lines changed

enterprise/coderd/workspaceproxy.go

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -58,26 +58,31 @@ func (api *API) regions(rw http.ResponseWriter, r *http.Request) {
5858
return
5959
}
6060

61-
proxyHealth := api.ProxyHealth.HealthStatus()
62-
for _, proxy := range proxies {
63-
if proxy.Deleted {
64-
continue
65-
}
66-
67-
health, ok := proxyHealth[proxy.ID]
68-
if !ok {
69-
health.Status = proxyhealth.Unknown
61+
// Only add additional regions if the proxy health is enabled.
62+
// If it is nil, it is because the moons feature flag is not on.
63+
// By default, we still want to return the primary region.
64+
if api.ProxyHealth != nil {
65+
proxyHealth := api.ProxyHealth.HealthStatus()
66+
for _, proxy := range proxies {
67+
if proxy.Deleted {
68+
continue
69+
}
70+
71+
health, ok := proxyHealth[proxy.ID]
72+
if !ok {
73+
health.Status = proxyhealth.Unknown
74+
}
75+
76+
regions = append(regions, codersdk.Region{
77+
ID: proxy.ID,
78+
Name: proxy.Name,
79+
DisplayName: proxy.DisplayName,
80+
IconURL: proxy.Icon,
81+
Healthy: health.Status == proxyhealth.Healthy,
82+
PathAppURL: proxy.Url,
83+
WildcardHostname: proxy.WildcardHostname,
84+
})
7085
}
71-
72-
regions = append(regions, codersdk.Region{
73-
ID: proxy.ID,
74-
Name: proxy.Name,
75-
DisplayName: proxy.DisplayName,
76-
IconURL: proxy.Icon,
77-
Healthy: health.Status == proxyhealth.Healthy,
78-
PathAppURL: proxy.Url,
79-
WildcardHostname: proxy.WildcardHostname,
80-
})
8186
}
8287

8388
httpapi.Write(ctx, rw, http.StatusOK, codersdk.RegionsResponse{

0 commit comments

Comments
 (0)