mirror of
https://codeberg.org/scip/esctl.git
synced 2026-08-24 17:24:18 +02:00
add -p -t -D flags to cluster settings ls (#10)
This commit is contained in:
@@ -140,6 +140,27 @@ func ClusterSettingsList(conf *cfg.Config) *cli.Command {
|
|||||||
Usage: "show cluster settings",
|
Usage: "show cluster settings",
|
||||||
Aliases: []string{"ls", "get"},
|
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 {
|
Action: func(ctx context.Context, cmd *cli.Command) error {
|
||||||
if err := es.ClusterSettingsList(conf); err != nil {
|
if err := es.ClusterSettingsList(conf); err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -39,20 +39,20 @@ type Cluster struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
ConfigFile string // -c
|
ConfigFile string // -c
|
||||||
CurrentCluster string // -C
|
CurrentCluster string // -C
|
||||||
Debug bool // -d
|
Debug bool // -d
|
||||||
Clusters map[string]*Cluster
|
Clusters map[string]*Cluster
|
||||||
DefaultCluster *Cluster
|
DefaultCluster *Cluster
|
||||||
Index string // index: -i
|
Index string // index: -i
|
||||||
Failed, Partials bool // index: flags
|
Failed, Partials bool // index: flags
|
||||||
Shards, Replicas int // index create: -s -r
|
Shards, Replicas int // index create: -s -r
|
||||||
Wait bool // index create: -w
|
Wait bool // index create: -w
|
||||||
From, To, MaxItems int // search: flags
|
From, To, MaxItems int // search: flags
|
||||||
Filter []string // search: -F
|
Filter []string // search: -F
|
||||||
Exclude string // cluster compare: -e (regexp)
|
Exclude string // cluster compare: -e (regexp)
|
||||||
All bool // cluster status: -a
|
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 {
|
func NewConfig() *Config {
|
||||||
|
|||||||
@@ -147,7 +147,16 @@ func ClusterSettingsList(conf *cfg.Config) error {
|
|||||||
table.Addheaders("setting", "value")
|
table.Addheaders("setting", "value")
|
||||||
entries := [][]string{}
|
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{}
|
data := map[string]map[string]any{}
|
||||||
|
|
||||||
err := json.Unmarshal(val, &data)
|
err := json.Unmarshal(val, &data)
|
||||||
|
|||||||
Reference in New Issue
Block a user