Skip to content

Commit

Permalink
Merge pull request #13 from po3rin/skip-exist-index-validation
Browse files Browse the repository at this point in the history
skip precheck for index that already exists
  • Loading branch information
po3rin authored Oct 7, 2021
2 parents 58cbfc6 + 18cd10f commit d40feea
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion check.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,18 @@ func (c *esclient) preCheck(ctx context.Context, conf config) error {
createIndices := make(map[string]struct{}, 0)

for _, ix := range conf.Indices {
ok, err := c.existIndex(ctx, ix.Name)
if err != nil {
return fmt.Errorf("pre-check: check index %v exists: %w", ix.Name, err)
}
if ok {
createIndices[ix.Name] = struct{}{}
c.logf("[skip] index %v already exists\n", ix.Name)
continue
}

createIndices[ix.Name] = struct{}{}
err := c.preCheckIndex(ctx, ix)
err = c.preCheckIndex(ctx, ix)
if err != nil {
c.logf("[fail] index: %v\n", ix.Name)
return err
Expand Down

0 comments on commit d40feea

Please sign in to comment.