@@ -10,8 +10,6 @@ import (
10
10
"net/http/httptest"
11
11
"strings"
12
12
13
- "github.com/coder/coder/v2/cli/cliutil"
14
-
15
13
"github.com/google/uuid"
16
14
"golang.org/x/sync/errgroup"
17
15
"golang.org/x/xerrors"
@@ -32,20 +30,20 @@ import (
32
30
// Even though we do attempt to sanitize data, it may still contain
33
31
// sensitive information and should thus be treated as secret.
34
32
type Bundle struct {
35
- Deployment Deployment `json:"deployment"`
36
- Network Network `json:"network"`
37
- Workspace Workspace `json:"workspace"`
38
- Agent Agent `json:"agent"`
39
- LicenseStatus string
40
- Logs []string `json:"logs"`
41
- CLILogs []byte `json:"cli_logs"`
33
+ Deployment Deployment `json:"deployment"`
34
+ Network Network `json:"network"`
35
+ Workspace Workspace `json:"workspace"`
36
+ Agent Agent `json:"agent"`
37
+ Logs []string `json:"logs"`
38
+ CLILogs []byte `json:"cli_logs"`
42
39
}
43
40
44
41
type Deployment struct {
45
42
BuildInfo * codersdk.BuildInfoResponse `json:"build"`
46
43
Config * codersdk.DeploymentConfig `json:"config"`
47
44
Experiments codersdk.Experiments `json:"experiments"`
48
45
HealthReport * healthsdk.HealthcheckReport `json:"health_report"`
46
+ Licenses []codersdk.License `json:"licenses"`
49
47
}
50
48
51
49
type Network struct {
@@ -141,6 +139,21 @@ func DeploymentInfo(ctx context.Context, client *codersdk.Client, log slog.Logge
141
139
return nil
142
140
})
143
141
142
+ eg .Go (func () error {
143
+ licenses , err := client .Licenses (ctx )
144
+ if err != nil {
145
+ // Ignore 404 because AGPL doesn't have this endpoint
146
+ if cerr , ok := codersdk .AsError (err ); ok && cerr .StatusCode () != http .StatusNotFound {
147
+ return xerrors .Errorf ("fetch license status: %w" , err )
148
+ }
149
+ }
150
+ if licenses == nil {
151
+ licenses = make ([]codersdk.License , 0 )
152
+ }
153
+ d .Licenses = licenses
154
+ return nil
155
+ })
156
+
144
157
if err := eg .Wait (); err != nil {
145
158
log .Error (ctx , "fetch deployment information" , slog .Error (err ))
146
159
}
@@ -354,27 +367,6 @@ func AgentInfo(ctx context.Context, client *codersdk.Client, log slog.Logger, ag
354
367
return a
355
368
}
356
369
357
- func LicenseStatus (ctx context.Context , client * codersdk.Client , log slog.Logger ) string {
358
- licenses , err := client .Licenses (ctx )
359
- if err != nil {
360
- log .Warn (ctx , "fetch licenses" , slog .Error (err ))
361
- return "No licenses found"
362
- }
363
- // Ensure that we print "[]" instead of "null" when there are no licenses.
364
- if licenses == nil {
365
- licenses = make ([]codersdk.License , 0 )
366
- }
367
-
368
- formatter := cliutil .NewLicenseFormatter (cliutil.LicenseFormatterOpts {
369
- Sanitize : true ,
370
- })
371
- out , err := formatter .Format (ctx , licenses )
372
- if err != nil {
373
- log .Error (ctx , "format licenses" , slog .Error (err ))
374
- }
375
- return out
376
- }
377
-
378
370
func connectedAgentInfo (ctx context.Context , client * codersdk.Client , log slog.Logger , agentID uuid.UUID , eg * errgroup.Group , a * Agent ) (closer func ()) {
379
371
conn , err := workspacesdk .New (client ).
380
372
DialAgent (ctx , agentID , & workspacesdk.DialAgentOptions {
@@ -534,11 +526,6 @@ func Run(ctx context.Context, d *Deps) (*Bundle, error) {
534
526
b .Agent = ai
535
527
return nil
536
528
})
537
- eg .Go (func () error {
538
- ls := LicenseStatus (ctx , d .Client , d .Log )
539
- b .LicenseStatus = ls
540
- return nil
541
- })
542
529
543
530
_ = eg .Wait ()
544
531
0 commit comments