mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 19:01:49 +00:00
Format json file with proper indentation
Signed-off-by: Dave Chen <dave.chen@arm.com>
This commit is contained in:
parent
eb729620c5
commit
dda8090037
@ -17,6 +17,7 @@ limitations under the License.
|
||||
package benchmark
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"flag"
|
||||
@ -173,8 +174,11 @@ func dataItems2JSONFile(dataItems DataItems, namePrefix string) error {
|
||||
}
|
||||
destFile = path.Join(*dataItemsDir, destFile)
|
||||
}
|
||||
|
||||
return ioutil.WriteFile(destFile, b, 0644)
|
||||
formatted := &bytes.Buffer{}
|
||||
if err := json.Indent(formatted, b, "", " "); err != nil {
|
||||
return fmt.Errorf("indenting error: %v", err)
|
||||
}
|
||||
return ioutil.WriteFile(destFile, formatted.Bytes(), 0644)
|
||||
}
|
||||
|
||||
type labelValues struct {
|
||||
|
Loading…
Reference in New Issue
Block a user