add -p -t -D flags to cluster settings ls (#10)

This commit is contained in:
T. von Dein
2026-05-06 07:25:27 +02:00
parent a71be5001a
commit af75bfa192
3 changed files with 45 additions and 15 deletions

View File

@@ -140,6 +140,27 @@ func ClusterSettingsList(conf *cfg.Config) *cli.Command {
Usage: "show cluster settings",
Aliases: []string{"ls", "get"},
Flags: []cli.Flag{
&cli.BoolFlag{
Name: "persistent",
Usage: "only show persistent setting[s] (default)",
Destination: &conf.Persistent,
Aliases: []string{"p"},
},
&cli.BoolFlag{
Name: "transient",
Usage: "only show transient setting[s]",
Destination: &conf.Transient,
Aliases: []string{"t"},
},
&cli.BoolFlag{
Name: "default",
Usage: "only show default setting[s]",
Destination: &conf.Default,
Aliases: []string{"D"},
},
},
Action: func(ctx context.Context, cmd *cli.Command) error {
if err := es.ClusterSettingsList(conf); err != nil {
return err

View File

@@ -52,7 +52,7 @@ type Config struct {
Filter []string // search: -F
Exclude string // cluster compare: -e (regexp)
All bool // cluster status: -a
Persistent, Transient bool // -p -t cluster settings set
Persistent, Transient, Default bool // -p -t -D cluster settings set
}
func NewConfig() *Config {

View File

@@ -147,7 +147,16 @@ func ClusterSettingsList(conf *cfg.Config) error {
table.Addheaders("setting", "value")
entries := [][]string{}
for topic, val := range res.Persistent {
settingshash := res.Persistent // == map[string]json.RawMessage
switch {
case conf.Transient:
settingshash = res.Transient
case conf.Default:
settingshash = res.Defaults
}
for topic, val := range settingshash {
data := map[string]map[string]any{}
err := json.Unmarshal(val, &data)