Skip to content

Commit 2143c62

Browse files
author
Josh Newman
committed
add string chunks helper function
1 parent 26e9dc5 commit 2143c62

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

cmd/common.go

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
package cmd
22

33
import (
4-
"github.com/jedib0t/go-pretty/table"
4+
"sort"
5+
"strings"
56
"time"
7+
8+
"github.com/aws/aws-sdk-go/service/ssm"
9+
"github.com/jedib0t/go-pretty/table"
610
)
711

812
func formatDate(dt *time.Time) string {
@@ -23,3 +27,20 @@ func insertColumn(row table.Row, index int, item interface{}) table.Row {
2327

2428
return row
2529
}
30+
31+
func getStringChunks(arr []*string, batchSize int) [][]*string {
32+
batches := make([][]*string, 0, (len(arr)+batchSize-1)/batchSize)
33+
34+
for batchSize < len(arr) {
35+
arr, batches = arr[batchSize:], append(batches, arr[0:batchSize:batchSize])
36+
}
37+
batches = append(batches, arr)
38+
39+
return batches
40+
}
41+
42+
func sortParams(params []*ssm.Parameter) {
43+
sort.Slice(params, func(i, j int) bool {
44+
return strings.ToLower(*params[i].Name) < strings.ToLower(*params[j].Name)
45+
})
46+
}

0 commit comments

Comments
 (0)