summaryrefslogtreecommitdiffstats
path: root/cmd-sdks.go
diff options
context:
space:
mode:
authorSebastien Douheret <sebastien.douheret@iot.bzh>2018-01-26 17:28:12 +0100
committerSebastien Douheret <sebastien.douheret@iot.bzh>2018-01-26 17:28:12 +0100
commit5ce05ccae810f532e73350a205b979faf2603235 (patch)
tree6a091bf3fad48f146d152f0336664dee8982a07c /cmd-sdks.go
parentc3c015d68a6f27bdb86c594ffbb481ee68f9e0c1 (diff)
Sort projects and sdks list.
Signed-off-by: Sebastien Douheret <sebastien.douheret@iot.bzh>
Diffstat (limited to 'cmd-sdks.go')
-rw-r--r--cmd-sdks.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/cmd-sdks.go b/cmd-sdks.go
index bc9df15..3fc596f 100644
--- a/cmd-sdks.go
+++ b/cmd-sdks.go
@@ -22,6 +22,7 @@ import (
"fmt"
"os"
"regexp"
+ "sort"
"gerrit.automotivelinux.org/gerrit/src/xds/xds-agent.git/lib/xaapiv1"
"github.com/urfave/cli"
@@ -204,6 +205,14 @@ func _displaySdks(sdks []xaapiv1.SDK, verbose bool, all bool, filter string) {
writer.Flush()
}
+// Sort SDKs by ID
+type _SdkByID []xaapiv1.SDK
+
+func (s _SdkByID) Len() int { return len(s) }
+func (s _SdkByID) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
+func (s _SdkByID) Less(i, j int) bool { return s[i].ID < s[j].ID }
+
+// _sdksListGet Get the list of existing sdks
func _sdksListGet(sdks *[]xaapiv1.SDK) error {
url := XdsServerComputeURL("/sdks")
if err := HTTPCli.Get(url, &sdks); err != nil {
@@ -211,6 +220,8 @@ func _sdksListGet(sdks *[]xaapiv1.SDK) error {
}
Log.Debugf("Result of %s: %v", url, sdks)
+ sort.Sort(_SdkByID(*sdks))
+
return nil
}