mirror of
https://codeberg.org/scip/esctl.git
synced 2026-08-24 06:34:18 +02:00
add alias+datastream rollover, and auto rollover on index tpl change (#40)
fixes #37
This commit is contained in:
@@ -36,8 +36,8 @@ func IndexAlias(conf *cfg.Config) *cli.Command {
|
||||
IndexAliasCreate(conf),
|
||||
IndexAliasList(conf),
|
||||
IndexAliasDelete(conf),
|
||||
// FIXME: implement IndexAliasShow + IndexAliasAdd
|
||||
//IndexAliasShow(conf),
|
||||
IndexAliasRollover(conf),
|
||||
// FIXME: implement IndexAliasAdd
|
||||
//IndexAliasAdd(conf), // see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-update-aliases
|
||||
},
|
||||
}
|
||||
@@ -91,6 +91,64 @@ func IndexAliasDelete(conf *cfg.Config) *cli.Command {
|
||||
}
|
||||
}
|
||||
|
||||
func IndexAliasRollover(conf *cfg.Config) *cli.Command {
|
||||
return &cli.Command{
|
||||
Name: "rollover",
|
||||
Aliases: []string{"roll"},
|
||||
Usage: "roll over an index alias",
|
||||
UsageText: "rollover <alias>",
|
||||
|
||||
ShellComplete: func(ctx context.Context, cmd *cli.Command) {
|
||||
complete(cmd, Cindex)
|
||||
},
|
||||
|
||||
Flags: []cli.Flag{
|
||||
&cli.BoolFlag{
|
||||
Name: "wait",
|
||||
Usage: "wait for active shards",
|
||||
Destination: &conf.Wait,
|
||||
Aliases: []string{"w"},
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "dry-run",
|
||||
Usage: "checks conditions but does not perform a rollover",
|
||||
Destination: &conf.Wait,
|
||||
Aliases: []string{"n"},
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "max-age",
|
||||
Usage: "roll over after max age (eg: 7d, 2m, 8h)",
|
||||
Destination: &conf.MaxAge,
|
||||
},
|
||||
&cli.IntFlag{
|
||||
Name: "max-docs",
|
||||
Usage: "roll over after max docs",
|
||||
Destination: &conf.MaxDocs,
|
||||
},
|
||||
&cli.IntFlag{
|
||||
Name: "max-primary-shard-size",
|
||||
Usage: "roll over when primary shard size reaches size",
|
||||
Destination: &conf.MaxShardSize,
|
||||
},
|
||||
&cli.IntFlag{
|
||||
Name: "max-primary-shard-docs",
|
||||
Usage: "roll over after max docs in primary shard reached",
|
||||
Destination: &conf.MaxShardDocs,
|
||||
},
|
||||
},
|
||||
|
||||
Action: func(ctx context.Context, cmd *cli.Command) error {
|
||||
alias := cmd.Args().Get(0)
|
||||
|
||||
if alias == "" {
|
||||
return errors.New("no alias specified")
|
||||
}
|
||||
|
||||
return es.IndexAliasRollover(conf, alias)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func IndexAliasList(conf *cfg.Config) *cli.Command {
|
||||
return &cli.Command{
|
||||
Name: "list",
|
||||
|
||||
Reference in New Issue
Block a user