@@ -8,14 +8,17 @@ import (
88 "time"
99
1010 "golang.org/x/xerrors"
11+
12+ "github.com/coder/coder/coderd/util/ptr"
1113)
1214
1315type AccessURLReport struct {
14- Healthy bool `json:"healthy"`
15- Reachable bool `json:"reachable"`
16- StatusCode int `json:"status_code"`
17- HealthzResponse string `json:"healthz_response"`
18- Error error `json:"error"`
16+ AccessURL string `json:"access_url"`
17+ Healthy bool `json:"healthy"`
18+ Reachable bool `json:"reachable"`
19+ StatusCode int `json:"status_code"`
20+ HealthzResponse string `json:"healthz_response"`
21+ Error * string `json:"error"`
1922}
2023
2124type AccessURLReportOptions struct {
@@ -28,36 +31,37 @@ func (r *AccessURLReport) Run(ctx context.Context, opts *AccessURLReportOptions)
2831 defer cancel ()
2932
3033 if opts .AccessURL == nil {
31- r .Error = xerrors . New ("access URL is nil" )
34+ r .Error = ptr . Ref ("access URL is nil" )
3235 return
3336 }
37+ r .AccessURL = opts .AccessURL .String ()
3438
3539 if opts .Client == nil {
3640 opts .Client = http .DefaultClient
3741 }
3842
3943 accessURL , err := opts .AccessURL .Parse ("/healthz" )
4044 if err != nil {
41- r .Error = xerrors .Errorf ("parse healthz endpoint: %w" , err )
45+ r .Error = convertError ( xerrors .Errorf ("parse healthz endpoint: %w" , err ) )
4246 return
4347 }
4448
4549 req , err := http .NewRequestWithContext (ctx , "GET" , accessURL .String (), nil )
4650 if err != nil {
47- r .Error = xerrors .Errorf ("create healthz request: %w" , err )
51+ r .Error = convertError ( xerrors .Errorf ("create healthz request: %w" , err ) )
4852 return
4953 }
5054
5155 res , err := opts .Client .Do (req )
5256 if err != nil {
53- r .Error = xerrors .Errorf ("get healthz endpoint: %w" , err )
57+ r .Error = convertError ( xerrors .Errorf ("get healthz endpoint: %w" , err ) )
5458 return
5559 }
5660 defer res .Body .Close ()
5761
5862 body , err := io .ReadAll (res .Body )
5963 if err != nil {
60- r .Error = xerrors .Errorf ("read healthz response: %w" , err )
64+ r .Error = convertError ( xerrors .Errorf ("read healthz response: %w" , err ) )
6165 return
6266 }
6367
0 commit comments