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

Function DeploymentInfo

support/support.go:147–332  ·  view source on GitHub ↗
(ctx context.Context, client *codersdk.Client, log slog.Logger, workspacesCap int)

Source from the content-addressed store, hash-verified

145}
146
147func DeploymentInfo(ctx context.Context, client *codersdk.Client, log slog.Logger, workspacesCap int) Deployment {
148 // Note: each goroutine assigns to a different struct field, hence no mutex.
149 var (
150 d Deployment
151 eg errgroup.Group
152 )
153
154 eg.Go(func() error {
155 bi, err := client.BuildInfo(ctx)
156 if err != nil {
157 return xerrors.Errorf("fetch build info: %w", err)
158 }
159 d.BuildInfo = &bi
160 return nil
161 })
162
163 eg.Go(func() error {
164 dc, err := client.DeploymentConfig(ctx)
165 if err != nil {
166 if cerr, ok := codersdk.AsError(err); ok && (cerr.StatusCode() == http.StatusForbidden || cerr.StatusCode() == http.StatusUnauthorized) {
167 log.Warn(ctx, "unable to fetch deployment config",
168 slog.F("status", cerr.StatusCode()))
169 return nil
170 }
171 return xerrors.Errorf("fetch deployment config: %w", err)
172 }
173 d.Config = dc
174 return nil
175 })
176
177 eg.Go(func() error {
178 hr, err := healthsdk.New(client).DebugHealth(ctx)
179 if err != nil {
180 if cerr, ok := codersdk.AsError(err); ok && (cerr.StatusCode() == http.StatusForbidden || cerr.StatusCode() == http.StatusUnauthorized) {
181 log.Warn(ctx, "unable to fetch health report",
182 slog.F("status", cerr.StatusCode()))
183 return nil
184 }
185 return xerrors.Errorf("fetch health report: %w", err)
186 }
187 d.HealthReport = &hr
188 return nil
189 })
190
191 eg.Go(func() error {
192 exp, err := client.Experiments(ctx)
193 if err != nil {
194 return xerrors.Errorf("fetch experiments: %w", err)
195 }
196 d.Experiments = exp
197 return nil
198 })
199
200 eg.Go(func() error {
201 licenses, err := client.Licenses(ctx)
202 if err != nil {
203 // Ignore 404 because AGPL doesn't have this endpoint
204 if cerr, ok := codersdk.AsError(err); ok && cerr.StatusCode() != http.StatusNotFound {

Callers 1

RunFunction · 0.85

Calls 15

AsErrorFunction · 0.92
NewFunction · 0.92
sanitizeEnvFunction · 0.85
fetchPrometheusMetricsFunction · 0.85
GoMethod · 0.80
BuildInfoMethod · 0.80
DeploymentConfigMethod · 0.80
DebugHealthMethod · 0.80
LicensesMethod · 0.80
EntitlementsMethod · 0.80
HealthSettingsMethod · 0.80
WorkspacesMethod · 0.80

Tested by

no test coverage detected