mirror of
https://github.com/cloudflare/cloudflared.git
synced 2025-07-27 19:09:58 +00:00
TUN-8784: Set JSON encoder options to print formatted JSON when writing diag files
## Summary The initial implementation produced correct JSON however it was not formatted which would make it harder to read the file by an user. Closes TUN-8784
This commit is contained in:
@@ -3,6 +3,7 @@ package diagnostic
|
||||
import (
|
||||
"archive/zip"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/url"
|
||||
@@ -138,3 +139,10 @@ func FindMetricsServer(
|
||||
|
||||
return nil, instances, ErrMultipleMetricsServerFound
|
||||
}
|
||||
|
||||
// newFormattedEncoder return a JSON encoder with identation
|
||||
func newFormattedEncoder(w io.Writer) *json.Encoder {
|
||||
encoder := json.NewEncoder(w)
|
||||
encoder.SetIndent("", " ")
|
||||
return encoder
|
||||
}
|
||||
|
Reference in New Issue
Block a user