Update init output to print pretty JSON.

reviewable/pr2557/r10
Justin Scott 8 years ago
parent 2889f97b5c
commit 6ab6e13576

@ -17,6 +17,8 @@ limitations under the License.
package main
import (
"bytes"
"encoding/json"
"errors"
"fmt"
"io"
@ -196,14 +198,20 @@ func (i *initCmd) run() error {
}
switch i.opts.Output.String() {
case "json":
var out bytes.Buffer
jsonb, err := yaml.ToJSON([]byte(body))
if err != nil {
if err := json.Indent(&out, jsonb, "", " "); err != nil {
return err
}
tm := []byte("{\"apiVersion\":\"extensions/v1beta1\",\"kind\":\"Deployment\",")
j := append(tm, jsonb[1:]...)
if err := json.Indent(&out, j, "", " "); err != nil {
return err
}
io.WriteString(i.out, "{\"apiVersion\":\"extensions/v1beta1\",\"kind\":\"Deployment\",")
if _, err = i.out.Write(jsonb[1:]); err != nil {
if _, err = i.out.Write(out.Bytes()); err != nil {
return err
}
return nil
case "yaml":
if err := writeYAMLManifest("extensions/v1beta1", "Deployment", body, true, false); err != nil {

Loading…
Cancel
Save