diff --git a/data/data.go b/data/data.go index 85d73cf..6b8dbe6 100644 --- a/data/data.go +++ b/data/data.go @@ -80,7 +80,7 @@ func (fi bindataFileInfo) Sys() interface{} { return nil } -var _pkgPullreqTemplatesApply_commentGotpl = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xbc\x53\x3b\x6e\x1b\x31\x10\xed\xf7\x14\x03\x28\x85\x2c\x60\xd7\xae\x05\xc5\x40\xbc\x49\x11\x18\x90\x0d\xe7\x53\xef\x6f\x24\x11\xa0\x48\x86\x1f\x0b\x02\xc5\x33\xa4\x4b\x91\x26\x29\x72\x88\x9c\x27\x17\x48\x8e\x10\xf0\xb3\xd6\xae\xa5\xda\xcd\xee\xfc\xf8\xe6\xcd\xf0\x71\x32\x99\xc0\xbf\x1f\xbf\xbe\xc1\xad\x69\xb0\x16\x82\xee\x21\x7e\x25\x2a\x43\x35\x58\x0b\x64\x05\xc5\x3b\xf6\x08\xce\x4d\xad\xed\xcd\x0b\x6b\x01\x59\x07\xce\x65\x99\xb5\x39\xbc\x6a\x70\x43\x58\x77\xb3\x87\xf9\x6b\x28\xee\x0d\xa5\x0f\xf8\xc5\xa0\xd2\x25\x25\xc8\x74\x71\xd3\xa7\x9d\x0b\xf5\x64\x05\x6b\x3d\x38\x75\xe5\x13\x7f\xbe\xff\xfc\xfb\xfb\x2b\x7c\xdc\x10\x05\xed\xa6\x66\x6b\x04\xa2\x20\xd6\x40\xe5\x9b\x9f\x01\xae\x15\x82\x73\x15\x34\x7b\x4f\xf6\x88\xe8\x1c\xb4\x7c\xbb\x25\x5a\x15\xa1\xe3\x90\xad\x1f\xa9\xa4\x46\x69\x94\x6f\x84\xa0\x04\x55\xcf\x4b\x86\xae\x67\x92\xd9\xc4\xaf\x2a\xc5\xe7\x91\x4d\xf2\x4a\xce\x56\x64\x5d\xbc\x45\xd5\x4a\x22\x34\x79\xc4\x65\xbd\x0d\xa4\x16\x8d\xbc\xbc\x0e\x9f\x0f\xa6\x11\xb5\xde\x28\x98\x9e\x1e\x4c\xb9\x92\x1b\xa6\xfd\x6a\xe7\x70\x5a\x73\x2f\x51\xeb\xfd\x13\x8a\x73\x47\xe8\x4f\xa2\xab\x35\x76\xfe\xc6\xb8\x91\x2d\xa6\x1e\x4b\xb3\x8d\x19\x15\x30\xb3\x6c\x21\xae\xfd\xf4\x7e\xf8\xe9\x5a\x8f\x0a\xae\x2e\xfc\x88\x07\xb8\xf5\x8b\x3e\x40\xa0\x1f\x7f\x4a\xd4\xad\xb7\xef\x68\x07\x9f\x51\x2a\xc2\x99\xcf\xe0\xee\xe8\x65\x07\xc8\xf3\x3c\x87\xd1\x2f\x7f\x6e\x9f\x7a\xc3\x7d\x3f\x04\xb5\xa9\x81\x3a\x8a\xf7\xaa\x94\x18\x06\x0b\xd4\xfc\x48\x81\x9e\x73\x10\xbd\xb4\xe4\x81\x17\xc9\x3e\x85\xee\x68\xd7\x93\x0c\xb1\xd9\x2c\x14\xe2\xee\x18\x9d\xcd\x12\x0f\xa4\x0a\x53\xdb\x7e\x9f\x2f\xd2\x36\x8a\xf2\xb9\x49\x83\xa6\xb3\xaa\xaa\xb2\x25\x1f\x5c\xec\x0e\x25\x82\x89\xfc\x8a\x90\x1e\x2a\x7b\x71\x19\x6f\x78\xac\xf5\x1e\x6c\xc9\xa1\x8d\x92\x4a\x2f\x9c\x0b\x94\xb5\x26\x9c\x25\xdc\x8e\x33\x1c\x3d\x95\xff\x01\x00\x00\xff\xff\x36\xb9\xce\x0e\x1c\x04\x00\x00") +var _pkgPullreqTemplatesApply_commentGotpl = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xbc\x53\x3b\x6e\x1b\x31\x10\xed\xf7\x14\x03\x28\x85\x2c\xc0\x6b\xd7\x82\x62\x20\xde\xa4\x08\x0c\xc8\x86\xf3\xa9\xf7\x37\x92\x08\x50\x24\xc3\x21\x2d\x08\x2b\x9e\x21\x5d\x8a\x34\x49\x91\x43\xe4\x3c\xb9\x40\x72\x84\x80\x9f\x95\x76\x63\xd5\xd9\x82\xcb\xf9\xf0\xcd\x9b\xe1\xe3\x64\x32\x81\x3f\xdf\x7e\x7c\x81\x3b\x5b\x63\xa5\x14\xdf\x43\x5c\x35\x92\xe5\x06\xba\x0e\xd8\x0a\xf2\x37\xe2\x09\x9c\x9b\x76\x5d\xbf\xbd\xe8\x3a\x40\xd1\x82\x73\x59\xd6\x75\x97\xf0\xa2\xc6\x0d\x13\xed\xed\x1e\xe6\x2f\x21\x7f\xb0\x9c\x3f\xe2\x27\x8b\x64\x0a\xce\x50\x98\xfc\xb6\x0f\x3b\x17\xf2\xd9\x0a\xd6\x66\x70\xea\xda\x07\x7e\x7d\xfd\xfe\xfb\xe7\x67\x78\xbf\x61\x04\xcd\xa6\x12\x6b\x04\x46\x10\x73\xa0\xf4\xc5\xcf\x00\x57\x84\xe0\x5c\x09\xf5\xde\x93\x3d\x21\x3a\x07\x8d\xdc\x6e\x99\xa1\x3c\x54\x1c\xb2\xf5\x2d\x15\xdc\x92\x41\xfd\x4a\x29\xce\x90\x7a\x5e\x3a\x54\x3d\x13\xcc\x26\x7e\x54\xc9\x3f\x8f\x6c\x92\x55\x48\xb1\x62\xeb\xfc\x35\x52\xa3\x99\x32\xec\x09\x97\xd5\x36\x90\x5a\xd4\xfa\xea\x26\x2c\xef\x6c\xad\x2a\xb3\x21\x98\x3e\x3f\x98\x62\x85\xb4\xc2\xf8\xd1\xce\xe1\x79\xce\x83\x46\x63\xf6\x47\x14\xe7\x4e\xd0\x1f\x54\x5b\x19\x6c\xfd\x8d\x49\xab\x1b\x4c\x35\x96\x76\x1b\x23\x14\x30\xb3\x6c\xa1\x6e\x7c\xf7\xbe\xf9\xe9\xda\x8c\x12\xae\x2f\x7c\x8b\x07\xf0\xbc\x49\x55\x0d\xc2\x01\xee\xfc\xd0\xa3\x0b\x0e\x70\xcf\x5b\xf8\x88\x9a\x98\x14\xde\x89\xbb\x93\x95\x1d\xe0\xb2\xff\x20\xee\xc7\xbf\x71\xec\x68\x0d\xe7\xfd\x18\xd4\x46\x03\x75\xe4\x6f\xa9\xd0\x18\x1a\x0b\xd4\x42\x4b\x47\x7a\xce\x41\x74\x05\x96\x47\x2b\xcd\x3d\x59\xf7\xbc\xed\x49\x06\xdf\x6c\x16\x72\x70\x77\xf2\xce\x66\x89\x07\x72\xc2\x54\xb6\x9f\xe7\x7f\x29\x1b\x45\xf9\xef\x96\x07\x4d\x67\x65\x59\x66\x4b\x39\xb8\xd8\x1d\x6a\x04\x1b\xf9\xe5\x21\x3c\x54\xf6\xe2\x2a\xde\xf0\x58\xeb\x3d\xd8\x52\x42\x13\x25\x95\x5e\xb8\x54\xa8\x2b\xc3\xa4\x48\xb8\xad\x14\x38\x7a\x2a\x7f\x03\x00\x00\xff\xff\x7c\xc1\x2b\x9c\x1c\x04\x00\x00") func pkgPullreqTemplatesApply_commentGotplBytes() ([]byte, error) { return bindataRead( @@ -95,8 +95,8 @@ func pkgPullreqTemplatesApply_commentGotpl() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "pkg/pullreq/templates/apply_comment.gotpl", size: 1052, mode: os.FileMode(0644), modTime: time.Unix(1611359084, 0)} - a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x8f, 0x3b, 0x3f, 0x4c, 0xd2, 0x9c, 0x22, 0x6, 0xa6, 0xf7, 0x75, 0x5c, 0xb5, 0xbe, 0x2a, 0xdf, 0xd8, 0xb8, 0xb4, 0x7, 0xff, 0x19, 0x4, 0x74, 0xff, 0x22, 0xce, 0x67, 0x1b, 0x98, 0x32, 0x3e}} + info := bindataFileInfo{name: "pkg/pullreq/templates/apply_comment.gotpl", size: 1052, mode: os.FileMode(0644), modTime: time.Unix(1611627862, 0)} + a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x39, 0x98, 0xb8, 0x81, 0x9e, 0xbb, 0x97, 0xdd, 0x58, 0x91, 0x82, 0x55, 0x99, 0xef, 0x6c, 0xc3, 0x49, 0xe7, 0xe0, 0x9d, 0x4, 0x30, 0x35, 0x16, 0xb9, 0xa3, 0x44, 0x34, 0x84, 0x2e, 0x0, 0x1b}} return a, nil } @@ -115,7 +115,7 @@ func pkgPullreqTemplatesDiff_commentGotpl() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "pkg/pullreq/templates/diff_comment.gotpl", size: 1228, mode: os.FileMode(0644), modTime: time.Unix(1611360952, 0)} + info := bindataFileInfo{name: "pkg/pullreq/templates/diff_comment.gotpl", size: 1228, mode: os.FileMode(0644), modTime: time.Unix(1611616180, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xee, 0x25, 0x58, 0x45, 0x7c, 0xdc, 0xb1, 0x76, 0x21, 0x29, 0x8e, 0x84, 0x5d, 0xb3, 0x29, 0xcf, 0x2e, 0x6e, 0xac, 0x9c, 0xd7, 0x94, 0xb5, 0xab, 0x64, 0xe6, 0x5b, 0xc3, 0x31, 0x9e, 0x7b, 0xcc}} return a, nil } @@ -135,7 +135,7 @@ func pkgPullreqTemplatesError_commentGotpl() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "pkg/pullreq/templates/error_comment.gotpl", size: 172, mode: os.FileMode(0644), modTime: time.Unix(1611361338, 0)} + info := bindataFileInfo{name: "pkg/pullreq/templates/error_comment.gotpl", size: 172, mode: os.FileMode(0644), modTime: time.Unix(1611616180, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x66, 0x91, 0x41, 0xaa, 0x31, 0xec, 0xcc, 0xde, 0x38, 0xc3, 0x60, 0xd2, 0xa0, 0x3c, 0x7f, 0xb1, 0xbe, 0x9e, 0x85, 0x37, 0x3, 0x9e, 0xd0, 0xc9, 0x9c, 0xab, 0x18, 0x16, 0xdf, 0x86, 0xf0, 0x79}} return a, nil } @@ -155,7 +155,7 @@ func pkgPullreqTemplatesHelp_commentGotpl() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "pkg/pullreq/templates/help_comment.gotpl", size: 1025, mode: os.FileMode(0644), modTime: time.Unix(1611253043, 0)} + info := bindataFileInfo{name: "pkg/pullreq/templates/help_comment.gotpl", size: 1025, mode: os.FileMode(0644), modTime: time.Unix(1611616180, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x2d, 0xd5, 0xd5, 0x14, 0xf7, 0xf3, 0x98, 0xc4, 0x7e, 0x8e, 0x37, 0x4c, 0x3a, 0x9a, 0x21, 0x20, 0xe2, 0xe, 0x6a, 0x1b, 0x92, 0x5e, 0x3a, 0x45, 0x4e, 0x7, 0x60, 0xe8, 0x65, 0x94, 0x37, 0xab}} return a, nil } @@ -255,7 +255,7 @@ func scriptsCreateLambdaBundleSh() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "scripts/create-lambda-bundle.sh", size: 819, mode: os.FileMode(0755), modTime: time.Unix(1611363512, 0)} + info := bindataFileInfo{name: "scripts/create-lambda-bundle.sh", size: 819, mode: os.FileMode(0755), modTime: time.Unix(1611616180, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x53, 0x3c, 0xc6, 0xbf, 0x2d, 0x5c, 0xb1, 0x3b, 0x37, 0x5, 0xa4, 0x16, 0x52, 0x5a, 0xd4, 0x49, 0xbb, 0xf8, 0x4, 0x83, 0x3c, 0xbf, 0x10, 0x39, 0xcf, 0x18, 0xbf, 0x52, 0x35, 0xee, 0xca, 0x3}} return a, nil } @@ -275,7 +275,7 @@ func scriptsKdiffWrapperSh() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "scripts/kdiff-wrapper.sh", size: 247, mode: os.FileMode(0755), modTime: time.Unix(1611288523, 0)} + info := bindataFileInfo{name: "scripts/kdiff-wrapper.sh", size: 247, mode: os.FileMode(0755), modTime: time.Unix(1611616180, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x1c, 0x65, 0xd, 0x2, 0xe5, 0x67, 0x2e, 0xc4, 0x79, 0xc0, 0x40, 0x6, 0x5c, 0x67, 0x6b, 0xbf, 0x64, 0x8, 0x19, 0x33, 0x6c, 0xa0, 0x14, 0x2f, 0x62, 0x59, 0xfc, 0x7e, 0x5d, 0x1b, 0xc9, 0x27}} return a, nil } @@ -315,7 +315,7 @@ func scriptsPullDepsSh() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "scripts/pull-deps.sh", size: 2203, mode: os.FileMode(0755), modTime: time.Unix(1611110571, 0)} + info := bindataFileInfo{name: "scripts/pull-deps.sh", size: 2203, mode: os.FileMode(0755), modTime: time.Unix(1611616180, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x82, 0x78, 0xdc, 0x27, 0x89, 0x9f, 0x3, 0x59, 0x10, 0xa2, 0xed, 0x2, 0x99, 0x9b, 0xa0, 0x37, 0x1a, 0xe0, 0x48, 0xde, 0x41, 0x99, 0xbf, 0x73, 0xf6, 0x7f, 0x94, 0xd8, 0xf8, 0xc, 0xad, 0xc0}} return a, nil } diff --git a/pkg/cluster/apply/format.go b/pkg/cluster/apply/format.go index a84a499..828f67b 100644 --- a/pkg/cluster/apply/format.go +++ b/pkg/cluster/apply/format.go @@ -15,9 +15,9 @@ func ResultsTextTable(results []Result) string { table := tablewriter.NewWriter(buf) table.SetHeader( []string{ + "Namespace", "Kind", "Name", - "Namespace", "Created", "Old Version", "New Version", @@ -60,9 +60,9 @@ func ResultsTextTable(results []Result) string { table.Append( []string{ + printer("%s", result.Namespace), printer("%s", result.Kind), printer("%s", result.Name), - printer("%s", result.Namespace), printer("%s", result.CreatedTimestamp()), printer("%s", result.OldVersion), printer("%s", result.NewVersion), diff --git a/pkg/cluster/diff/format.go b/pkg/cluster/diff/format.go index cd9792f..4a0e3c9 100644 --- a/pkg/cluster/diff/format.go +++ b/pkg/cluster/diff/format.go @@ -14,9 +14,9 @@ func ResultsTable(results []Result) string { table := tablewriter.NewWriter(buf) table.SetHeader( []string{ + "Namespace", "Kind", "Name", - "Namespace", "Changed Lines", }, ) @@ -53,9 +53,9 @@ func ResultsTable(results []Result) string { table.Append( []string{ + namespace, kind, name, - namespace, fmt.Sprintf("%d", result.NumChangedLines()), }, ) diff --git a/pkg/cluster/kube_client.go b/pkg/cluster/kube_client.go index a480f67..dda8da3 100644 --- a/pkg/cluster/kube_client.go +++ b/pkg/cluster/kube_client.go @@ -195,7 +195,11 @@ func (cc *KubeClusterClient) ApplyStructured( return nil, err } - return apply.ObjsToResults(oldObjs, newObjs) + results, err := apply.ObjsToResults(oldObjs, newObjs) + if err != nil { + return nil, err + } + return sortedApplyResults(results), nil } // Diff runs a kubectl diff between the configs at the argument path and the associated @@ -238,7 +242,7 @@ func (cc *KubeClusterClient) DiffStructured( if err := json.Unmarshal(rawResults, &results); err != nil { return nil, err } - return results.Results, nil + return sortedDiffResults(results.Results), nil } // Summary returns a summary of the current cluster state. diff --git a/pkg/cluster/sort.go b/pkg/cluster/sort.go new file mode 100644 index 0000000..0a336f8 --- /dev/null +++ b/pkg/cluster/sort.go @@ -0,0 +1,112 @@ +package cluster + +import ( + "sort" + "strconv" + "strings" + + "github.com/segmentio/kubeapply/pkg/cluster/apply" + "github.com/segmentio/kubeapply/pkg/cluster/diff" +) + +type wrappedResult struct { + nameBase string + nameIndex int + namespaceBase string + namespaceIndex int + kind string + resultIndex int +} + +// sortedDiffResults sorts diff results by namespace, then resource type, +// then resource name. If a resource name or namespace is structured as +// [base string]-[number], then the number is used to break ties among all +// entities with the same base. +func sortedDiffResults(results []diff.Result) []diff.Result { + wrappedResults := make([]wrappedResult, len(results)) + for r, result := range results { + if result.Object != nil { + wrappedResults[r].nameBase, wrappedResults[r].nameIndex = + parseName(result.Object.Name) + wrappedResults[r].namespaceBase, wrappedResults[r].namespaceIndex = + parseName(result.Object.Namespace) + wrappedResults[r].kind = result.Object.Kind + } else { + wrappedResults[r].namespaceBase = result.Name + } + wrappedResults[r].resultIndex = r + } + + sortWrappedResults(wrappedResults) + + sortedResults := make([]diff.Result, len(results)) + for r, wrappedResult := range wrappedResults { + sortedResults[r] = results[wrappedResult.resultIndex] + } + + return sortedResults +} + +// sortedApplyResults sorts apply results by namespace, then resource type, +// then resource name. If a resource name or namespace is structured as +// [base string]-[number], then the number is used to break ties among all +// entities with the same base. +func sortedApplyResults(results []apply.Result) []apply.Result { + wrappedResults := make([]wrappedResult, len(results)) + for r, result := range results { + wrappedResults[r].nameBase, wrappedResults[r].nameIndex = + parseName(result.Name) + wrappedResults[r].namespaceBase, wrappedResults[r].namespaceIndex = + parseName(result.Namespace) + wrappedResults[r].kind = result.Kind + wrappedResults[r].resultIndex = r + } + + sortWrappedResults(wrappedResults) + + sortedResults := make([]apply.Result, len(results)) + for r, wrappedResult := range wrappedResults { + sortedResults[r] = results[wrappedResult.resultIndex] + } + + return sortedResults +} + +func sortWrappedResults(wrappedResults []wrappedResult) { + sort.Slice(wrappedResults, func(a, b int) bool { + result1 := wrappedResults[a] + result2 := wrappedResults[b] + if result1.namespaceBase < result2.namespaceBase { + return true + } else if result1.namespaceBase > result2.namespaceBase { + return false + } else if result1.namespaceIndex < result2.namespaceIndex { + return true + } else if result1.namespaceIndex > result2.namespaceIndex { + return false + } else if result1.kind < result2.kind { + return true + } else if result1.kind > result2.kind { + return false + } else if result1.nameBase < result2.nameBase { + return true + } else if result1.nameBase > result2.nameBase { + return false + } else if result1.nameIndex < result2.nameIndex { + return true + } + return false + }) +} + +func parseName(name string) (string, int) { + components := strings.Split(name, "-") + if len(components) < 2 { + return name, 0 + } + index, err := strconv.Atoi(components[len(components)-1]) + if err != nil { + return name, 0 + } + return strings.Join(components[0:len(components)-1], "-"), index +} diff --git a/pkg/cluster/sort_test.go b/pkg/cluster/sort_test.go new file mode 100644 index 0000000..a1bf36c --- /dev/null +++ b/pkg/cluster/sort_test.go @@ -0,0 +1,147 @@ +package cluster + +import ( + "testing" + + "github.com/segmentio/kubeapply/pkg/cluster/apply" + "github.com/segmentio/kubeapply/pkg/cluster/diff" + "github.com/stretchr/testify/assert" +) + +func TestSortedDiffResults(t *testing.T) { + diffResults := []diff.Result{ + { + Object: &apply.TypedKubeObj{ + KubeMetadata: apply.KubeMetadata{ + Name: "test-name", + Namespace: "test-namespace-1", + }, + Kind: "test-kind", + }, + Name: "resource-0", + }, + { + Object: &apply.TypedKubeObj{ + KubeMetadata: apply.KubeMetadata{ + Name: "test-name", + Namespace: "test-namespace-10", + }, + Kind: "test-kind", + }, + Name: "resource-1", + }, + { + Object: &apply.TypedKubeObj{ + KubeMetadata: apply.KubeMetadata{ + Name: "test-name", + Namespace: "test-namespace-2", + }, + Kind: "test-kind", + }, + Name: "resource-2", + }, + { + Object: &apply.TypedKubeObj{ + KubeMetadata: apply.KubeMetadata{ + Name: "test-name", + Namespace: "another-namespace", + }, + Kind: "test-kind", + }, + Name: "resource-3", + }, + { + Object: &apply.TypedKubeObj{ + KubeMetadata: apply.KubeMetadata{ + Name: "test-name", + Namespace: "another-namespace", + }, + Kind: "another-kind", + }, + Name: "resource-4", + }, + { + Object: &apply.TypedKubeObj{ + KubeMetadata: apply.KubeMetadata{ + Name: "test-name-x", + Namespace: "another-namespace", + }, + Kind: "test-kind", + }, + Name: "resource-5", + }, + { + Name: "resource-6", + }, + } + + sortedResults := sortedDiffResults(diffResults) + assert.Equal( + t, + sortedResults, + []diff.Result{ + diffResults[4], + diffResults[3], + diffResults[5], + diffResults[6], + diffResults[0], + diffResults[2], + diffResults[1], + }, + ) +} + +func TestSortedApplyResults(t *testing.T) { + applyResults := []apply.Result{ + { + Name: "resource-5", + Namespace: "test-namespace-003", + Kind: "test-kind", + OldVersion: "0", + }, + { + Name: "resource-1", + Namespace: "test-namespace-10", + Kind: "test-kind", + OldVersion: "1", + }, + { + Name: "resource-2", + Namespace: "test-namespace-3", + Kind: "test-kind", + OldVersion: "2", + }, + { + Name: "resource-3", + Namespace: "another-namespace", + Kind: "test-kind", + OldVersion: "3", + }, + { + Name: "resource-10", + Namespace: "another-namespace", + Kind: "test-kind", + OldVersion: "4", + }, + { + Name: "resource-100", + Namespace: "another-namespace", + Kind: "another-kind", + OldVersion: "5", + }, + } + + sortedResults := sortedApplyResults(applyResults) + assert.Equal( + t, + sortedResults, + []apply.Result{ + applyResults[5], + applyResults[3], + applyResults[4], + applyResults[2], + applyResults[0], + applyResults[1], + }, + ) +} diff --git a/pkg/pullreq/templates/apply_comment.gotpl b/pkg/pullreq/templates/apply_comment.gotpl index eb529e4..b67a716 100644 --- a/pkg/pullreq/templates/apply_comment.gotpl +++ b/pkg/pullreq/templates/apply_comment.gotpl @@ -13,13 +13,13 @@
{{ if (gt .NumUpdates 0) }} -| Kind | Name | Namespace | Old Version | New Version | -| ---- | ---- | --------- | ----------- | ----------- | +| Namespace | Kind | Name | Old Version | New Version | +| --------- | ---- | ---- | ----------- | ----------- | {{- range .Results }} {{- if .IsCreated }} -| {{ .Kind }} | {{ .Name }} | {{ .Namespace }} | {{ .OldVersion }} | **{{ .NewVersion }}** | +| {{ .Namespace }} | {{ .Kind }} | {{ .Name }} | {{ .OldVersion }} | **{{ .NewVersion }}** | {{- else if .IsUpdated }} -| {{ .Kind }} | {{ .Name }} | {{ .Namespace }} | {{ .OldVersion }} | **{{ .NewVersion }}** | +| {{ .Namespace }} | {{ .Kind }} | {{ .Name }} | {{ .OldVersion }} | **{{ .NewVersion }}** | {{- end }} {{- end }} {{- else }} diff --git a/pkg/pullreq/testdata/comments/apply.md b/pkg/pullreq/testdata/comments/apply.md index 376055d..b79cc6c 100644 --- a/pkg/pullreq/testdata/comments/apply.md +++ b/pkg/pullreq/testdata/comments/apply.md @@ -5,9 +5,9 @@
-| Kind | Name | Namespace | Old Version | New Version | -| ---- | ---- | --------- | ----------- | ----------- | -| test-kind | test-name | test-namespace | 1234 | **3456** | +| Namespace | Kind | Name | Old Version | New Version | +| --------- | ---- | ---- | ----------- | ----------- | +| test-namespace | test-kind | test-name | 1234 | **3456** |
@@ -16,9 +16,9 @@-| Kind | Name | Namespace | Old Version | New Version | -| ---- | ---- | --------- | ----------- | ----------- | -| test-kind3 | test-name3 | test-namespace3 | 1234 | **3456** | +| Namespace | Kind | Name | Old Version | New Version | +| --------- | ---- | ---- | ----------- | ----------- | +| test-namespace3 | test-kind3 | test-name3 | 1234 | **3456** |