mirror of
https://codeberg.org/scip/esctl.git
synced 2026-08-24 13:04:20 +02:00
add support for config file and multiple clusters config (#1)
This commit is contained in:
@@ -26,7 +26,7 @@ import (
|
||||
)
|
||||
|
||||
func Health(conf *cfg.Config) error {
|
||||
res, err := conf.ES.Cluster.Health().Do(context.Background())
|
||||
res, err := conf.DefaultCluster.ES.Cluster.Health().Do(context.Background())
|
||||
if err != nil {
|
||||
log.Fatalf("Error getting health: %s", err)
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ import (
|
||||
)
|
||||
|
||||
func IndexList(conf *cfg.Config) error {
|
||||
cat := conf.ES.Cat.Indices()
|
||||
cat := conf.DefaultCluster.ES.Cat.Indices()
|
||||
|
||||
if conf.Failed {
|
||||
cat = cat.Health(healthstatus.Red)
|
||||
@@ -67,7 +67,7 @@ func IndexList(conf *cfg.Config) error {
|
||||
}
|
||||
|
||||
func IndexShow(conf *cfg.Config, index string) error {
|
||||
res, err := conf.ES.Indices.Get(index).Do(context.Background())
|
||||
res, err := conf.DefaultCluster.ES.Indices.Get(index).Do(context.Background())
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to get index: %s", err)
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ func Search(conf *cfg.Config, q string) error {
|
||||
query.Filter(filters...)
|
||||
}
|
||||
|
||||
res, err := conf.ES.Search().
|
||||
res, err := conf.DefaultCluster.ES.Search().
|
||||
Index(conf.Index).
|
||||
Request(&search.Request{
|
||||
Query: query.QueryCaster(),
|
||||
|
||||
@@ -42,7 +42,7 @@ type Snapshot struct {
|
||||
|
||||
func SnapshotList(conf *cfg.Config) error {
|
||||
// get partial indicies
|
||||
ires, err := conf.ES.Cat.Indices().Do(context.Background())
|
||||
ires, err := conf.DefaultCluster.ES.Cat.Indices().Do(context.Background())
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error getting indicies: %s", err)
|
||||
}
|
||||
@@ -55,7 +55,7 @@ func SnapshotList(conf *cfg.Config) error {
|
||||
}
|
||||
|
||||
// get snapshots
|
||||
sres, err := conf.ES.Cat.Snapshots().Do(context.Background())
|
||||
sres, err := conf.DefaultCluster.ES.Cat.Snapshots().Do(context.Background())
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error getting snapshots: %s", err)
|
||||
}
|
||||
@@ -103,7 +103,7 @@ func SnapshotList(conf *cfg.Config) error {
|
||||
}
|
||||
|
||||
func SnapshotShow(conf *cfg.Config, snapshot string) error {
|
||||
res, err := conf.ES.Snapshot.Get("*", snapshot).Do(context.Background())
|
||||
res, err := conf.DefaultCluster.ES.Snapshot.Get("*", snapshot).Do(context.Background())
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to get snapshot: %s", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user