mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
Merge pull request #104808 from chendave/indent
Format json file with proper indentation
This commit is contained in:
commit
857d4c107c
@ -17,6 +17,7 @@ limitations under the License.
|
|||||||
package benchmark
|
package benchmark
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"flag"
|
"flag"
|
||||||
@ -173,8 +174,11 @@ func dataItems2JSONFile(dataItems DataItems, namePrefix string) error {
|
|||||||
}
|
}
|
||||||
destFile = path.Join(*dataItemsDir, destFile)
|
destFile = path.Join(*dataItemsDir, destFile)
|
||||||
}
|
}
|
||||||
|
formatted := &bytes.Buffer{}
|
||||||
return ioutil.WriteFile(destFile, b, 0644)
|
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 {
|
type labelValues struct {
|
||||||
|
Loading…
Reference in New Issue
Block a user