Skip to content

Commit

Permalink
add deployment order, fix json format
Browse files Browse the repository at this point in the history
  • Loading branch information
ngtuna committed Dec 20, 2017
1 parent 1540a92 commit 110f595
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions cmd/up.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"encoding/json"
"fmt"
"io"
"sort"
"strconv"
"strings"

Expand Down Expand Up @@ -188,6 +189,7 @@ func init() {

func dump(w io.Writer, out string, objs []*unstructured.Unstructured) error {
bObjs := [][]byte{}
sort.Sort(utils.DependencyOrder(objs))

switch out {
case "json":
Expand All @@ -199,15 +201,7 @@ func dump(w io.Writer, out string, objs []*unstructured.Unstructured) error {
bObjs = append(bObjs, j)
}

b := bytes.Join(bObjs, []byte(fmt.Sprintf(",\n")))
// insert '[' to the front
b = append(b, 0)
copy(b[1:], b[0:])
b[0] = byte('[')

// append ']'
b = append(b, ']')

b := bytes.Join(bObjs, []byte(fmt.Sprintf("\n")))
fmt.Fprintln(w, string(b[:]))

case "yaml":
Expand Down

0 comments on commit 110f595

Please sign in to comment.