enhanced default cluster selection, add 'cluster switch', overhaul json header setting (#47)

This commit is contained in:
T. von Dein
2026-06-24 09:25:50 +02:00
parent 3c6819151f
commit ffcb8adb70
26 changed files with 393 additions and 320 deletions

View File

@@ -30,9 +30,7 @@ import (
)
func DatastreamNames(conf *cfg.Config) ([]string, error) {
res, err := conf.DefaultCluster.ES.Indices.GetDataStream().
Header("content-type", "application/json").
Header("accept", "application/json").
res, err := conf.DefaultCluster.ES().Indices.GetDataStream().
Do(context.Background())
if err != nil {
return nil, fmt.Errorf("failed to get data streams: %s", esErrorString(err))
@@ -47,9 +45,7 @@ func DatastreamNames(conf *cfg.Config) ([]string, error) {
}
func DatastreamList(conf *cfg.Config) error {
res, err := conf.DefaultCluster.ES.Indices.GetDataStream().
Header("content-type", "application/json").
Header("accept", "application/json").
res, err := conf.DefaultCluster.ES().Indices.GetDataStream().
Do(context.Background())
if err != nil {
return fmt.Errorf("failed to get data streams: %s", esErrorString(err))
@@ -129,10 +125,8 @@ func filterDatastreams(conf *cfg.Config, list []types.DataStream) []types.DataSt
}
func DatastreamShow(conf *cfg.Config, dsname string) error {
res, err := conf.DefaultCluster.ES.Indices.GetDataStream().
res, err := conf.DefaultCluster.ES().Indices.GetDataStream().
Name(dsname).
Header("content-type", "application/json").
Header("accept", "application/json").
Do(context.Background())
if err != nil {
return fmt.Errorf("failed to get data stream: %s", esErrorString(err))
@@ -144,10 +138,8 @@ func DatastreamShow(conf *cfg.Config, dsname string) error {
return errors.New("no data stream found with that name")
}
stats, err := conf.DefaultCluster.ES.Indices.DataStreamsStats().
stats, err := conf.DefaultCluster.ES().Indices.DataStreamsStats().
Name(dsname).
Header("content-type", "application/json").
Header("accept", "application/json").
Do(context.Background())
if err != nil {
return fmt.Errorf("failed to get data stream stats: %s", esErrorString(err))
@@ -213,9 +205,7 @@ func DatastreamShow(conf *cfg.Config, dsname string) error {
}
func DatastreamCreate(conf *cfg.Config, dsname string) error {
_, err := conf.DefaultCluster.ES.Indices.CreateDataStream(dsname).
Header("content-type", "application/json").
Header("accept", "application/json").
_, err := conf.DefaultCluster.ES().Indices.CreateDataStream(dsname).
Do(context.Background())
if err != nil {
@@ -226,9 +216,7 @@ func DatastreamCreate(conf *cfg.Config, dsname string) error {
}
func DatastreamDelete(conf *cfg.Config, dsname string) error {
_, err := conf.DefaultCluster.ES.Indices.DeleteDataStream(dsname).
Header("content-type", "application/json").
Header("accept", "application/json").
_, err := conf.DefaultCluster.ES().Indices.DeleteDataStream(dsname).
Do(context.Background())
if err != nil {