From 15abdb47412ad59a3f69a634e5969887947719f0 Mon Sep 17 00:00:00 2001
From: Pavol Loffay
Date: Fri, 15 Oct 2021 02:00:10 +0200
Subject: [PATCH] Fix args order in strings.Contains in es-rollover (#3324)
If we do `strings.Contains("resource_already_exists_exception", errorMap["type"].(string))`,
we're basically doing `"resource_already_exists_exception" == errorMap["type"].(string)`.
I would assume that we intended to test whether `errorMap["type"]` contains
`"resource_already_exists_exception"` as a substring, so the reverse `strings.Contains` order
is more applicable here.
Signed-off-by: Pavol Loffay
Co-authored-by: Iskander (Alex) Sharipov
Co-authored-by: Albert <26584478+albertteoh@users.noreply.github.com>
---
cmd/es-rollover/app/init/action.go | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/cmd/es-rollover/app/init/action.go b/cmd/es-rollover/app/init/action.go
index 73c55ab13d0..e103336bad3 100644
--- a/cmd/es-rollover/app/init/action.go
+++ b/cmd/es-rollover/app/init/action.go
@@ -94,7 +94,7 @@ func createIndexIfNotExist(c client.IndexAPI, index string) error {
}
errorMap := jsonError["error"].(map[string]interface{})
// check for reason, ignore already exist error
- if strings.Contains("resource_already_exists_exception", errorMap["type"].(string)) {
+ if strings.Contains(errorMap["type"].(string), "resource_already_exists_exception") {
return nil
}
}