Skip to content

Commit

Permalink
Add prefix param for show configuration command (#232)
Browse files Browse the repository at this point in the history
Signed-off-by: Congqi Xia <[email protected]>
  • Loading branch information
congqixia authored Dec 26, 2023
1 parent 19741bb commit 2dba248
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion states/visit.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"errors"
"fmt"
"strconv"
"strings"

"github.com/milvus-io/birdwatcher/models"
"github.com/milvus-io/birdwatcher/proto/v2.0/commonpb"
Expand Down Expand Up @@ -217,6 +218,11 @@ func getConfigurationCmd(client configurationSource, id int64) *cobra.Command {
Short: "call ShowConfigurations for config inspection",
Aliases: []string{"GetConfigurations", "configurations"},
Run: func(cmd *cobra.Command, args []string) {
prefix, err := cmd.Flags().GetString("prefix")
if err != nil {
fmt.Println(err.Error())
return
}
resp, err := client.ShowConfigurations(context.Background(), &internalpbv2.ShowConfigurationsRequest{
Base: &commonpbv2.MsgBase{
SourceID: -1,
Expand All @@ -227,11 +233,16 @@ func getConfigurationCmd(client configurationSource, id int64) *cobra.Command {
fmt.Println(err.Error())
return
}
prefix = strings.ToLower(prefix)
for _, item := range resp.GetConfiguations() {
fmt.Printf("Key: %s, Value: %s\n", item.Key, item.Value)
if strings.HasPrefix(item.GetKey(), prefix) {
fmt.Printf("Key: %s, Value: %s\n", item.Key, item.Value)
}
}
},
}

cmd.Flags().String("prefix", "", "the configuration prefix to show")

return cmd
}

0 comments on commit 2dba248

Please sign in to comment.