mirror of
https://codeberg.org/scip/esctl.git
synced 2026-08-24 06:34:18 +02:00
Add CCR stuff, fix search, add docs support, support index maps, refactor (#13)
This commit is contained in:
108
cmd/ccr_follower.go
Normal file
108
cmd/ccr_follower.go
Normal file
@@ -0,0 +1,108 @@
|
||||
/*
|
||||
Copyright © 2026 Thomas von Dein
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
"codeberg.org/scip/esctl/pkg/cfg"
|
||||
"codeberg.org/scip/esctl/pkg/es"
|
||||
|
||||
"github.com/urfave/cli/v3"
|
||||
)
|
||||
|
||||
func CcrFollower(conf *cfg.Config) *cli.Command {
|
||||
return &cli.Command{
|
||||
Name: "follower",
|
||||
Aliases: []string{"f"},
|
||||
Usage: "manage ccr follower indices",
|
||||
|
||||
Commands: []*cli.Command{
|
||||
CcrFollowerShow(conf),
|
||||
CcrFollowerAdd(conf),
|
||||
CcrFollowerDelete(conf),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func CcrFollowerAdd(conf *cfg.Config) *cli.Command {
|
||||
return &cli.Command{
|
||||
Name: "add",
|
||||
Aliases: []string{"+"},
|
||||
Usage: "add ccr follower index",
|
||||
UsageText: "add [options] <index>",
|
||||
|
||||
Flags: []cli.Flag{
|
||||
&cli.BoolFlag{
|
||||
Name: "wait",
|
||||
Usage: "wait for active shards",
|
||||
Destination: &conf.Wait,
|
||||
Aliases: []string{"w"},
|
||||
},
|
||||
},
|
||||
|
||||
Action: func(ctx context.Context, cmd *cli.Command) error {
|
||||
args := cmd.Args()
|
||||
|
||||
if args.Len() != 1 {
|
||||
return errors.New("missing arguments: <index>")
|
||||
}
|
||||
|
||||
return es.CcrFollowerAdd(conf, cmd.Args().Get(0))
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func CcrFollowerDelete(conf *cfg.Config) *cli.Command {
|
||||
return &cli.Command{
|
||||
Name: "delete",
|
||||
Aliases: []string{"-"},
|
||||
Usage: "delete ccr follower index",
|
||||
UsageText: "delete <index>",
|
||||
|
||||
Action: func(ctx context.Context, cmd *cli.Command) error {
|
||||
args := cmd.Args()
|
||||
|
||||
if args.Len() != 1 {
|
||||
return errors.New("missing arguments: <index>")
|
||||
}
|
||||
|
||||
// just an alias to index delete
|
||||
return es.IndexDelete(conf, cmd.Args().Get(0))
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func CcrFollowerShow(conf *cfg.Config) *cli.Command {
|
||||
return &cli.Command{
|
||||
Name: "show",
|
||||
Aliases: []string{"sh"},
|
||||
Usage: "show ccr follower index details",
|
||||
UsageText: "show <index>",
|
||||
|
||||
Action: func(ctx context.Context, cmd *cli.Command) error {
|
||||
args := cmd.Args()
|
||||
|
||||
if args.Len() != 1 {
|
||||
return errors.New("missing arguments: <index>")
|
||||
}
|
||||
|
||||
return es.CcrFollowerShow(conf, cmd.Args().Get(0))
|
||||
},
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user