(ctx context.Context, client *codersdk.Client, log slog.Logger, workspacesCap int)
| 145 | } |
| 146 | |
| 147 | func 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 { |
no test coverage detected