From 8dd7698f83e9f10f79fae598df4c8430748b0e41 Mon Sep 17 00:00:00 2001 From: Sax Authors Date: Tue, 29 Oct 2024 15:15:07 -0700 Subject: [PATCH] Add a test case for saxutil getacl model all. PiperOrigin-RevId: 691179379 Change-Id: I5832379bd8cbff1ca61a0a38d149cce131774676 --- saxml/bin/BUILD | 1 + saxml/bin/saxutil_cmd_admin.go | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/saxml/bin/BUILD b/saxml/bin/BUILD index 26b349f2..7673a8b1 100644 --- a/saxml/bin/BUILD +++ b/saxml/bin/BUILD @@ -64,6 +64,7 @@ go_library( "//saxml/common/platform:env", "//saxml/protobuf:admin_go_proto_grpc", "//saxml/protobuf:common_go_proto", + "//third_party/golang/go_exp/maps", "@com_github_golang_glog//:go_default_library", "@com_github_google_subcommands//:go_default_library", "@com_github_olekukonko_tablewriter//:go_default_library", diff --git a/saxml/bin/saxutil_cmd_admin.go b/saxml/bin/saxutil_cmd_admin.go index 216aab82..aadf5c2d 100644 --- a/saxml/bin/saxutil_cmd_admin.go +++ b/saxml/bin/saxutil_cmd_admin.go @@ -22,6 +22,7 @@ import ( "math/rand" "os" "path/filepath" + "slices" "sort" "strconv" "strings" @@ -29,6 +30,7 @@ import ( "flag" log "github.com/golang/glog" // Internal storage imports + "google3/third_party/golang/go_exp/maps/maps" "google.golang.org/protobuf/proto" "github.com/google/subcommands" "github.com/olekukonko/tablewriter" @@ -731,8 +733,11 @@ func (c *GetACLCmd) handleSaxModel(ctx context.Context, modelFullName naming.Mod } method := args[1] if method == "all" { - for k, v := range items { - fmt.Printf("%s: %s\n", k, v) + // Sort the keys of the map. + keys := maps.Keys(items) + slices.Sort(keys) + for _, k := range keys { + fmt.Printf("%s: %s\n", k, items[k]) } } else { acl, ok := items[method]