From f5b64850af841a5f8bf573f5b1cf81cfcdc873cd Mon Sep 17 00:00:00 2001 From: Aditya <60684641+0x0elliot@users.noreply.github.com> Date: Sat, 14 Oct 2023 15:49:12 +0530 Subject: [PATCH] fix: fixed #43 --- health.go | 53 +++++++++++++++++++++++++++++++++++------------------ 1 file changed, 35 insertions(+), 18 deletions(-) diff --git a/health.go b/health.go index 21eacbb8..964b72f4 100644 --- a/health.go +++ b/health.go @@ -702,33 +702,50 @@ func fixOpensearch() error { // Define the index mapping mapping := `{ "properties": { - "workflow": { + "workflow": { + "properties": { + "actions": { "properties": { - "actions": { - "properties": { - "parameters": { - "properties": { - "value": { - "type": "text" - }, - "example": { - "type": "text" - }, - } - } - } + "parameters": { + "properties": { + "value": { + "type": "text" + }, + "example": { + "type": "text" + } } + } } + } } + } } - }` + }` // Get the username and password from environment variables - username := os.Getenv("OPENSEARCH_USERNAME") - password := os.Getenv("OPENSEARCH_PASSWORD") - opensearchUrl := os.Getenv("OPENSEARCH_URL") + username := os.Getenv("SHUFFLE_OPENSEARCH_USERNAME") + if len(username) == 0 { + log.Printf("[DEBUG] Opensearch username not set. Setting to default") + username = "admin" + } + + password := os.Getenv("SHUFFLE_OPENSEARCH_PASSWORD") + if len(password) == 0 { + log.Printf("[DEBUG] Opensearch password not set. Setting to default") + password = "admin" + } + + opensearchUrl := os.Getenv("SHUFFLE_OPENSEARCH_URL") + if len(opensearchUrl) == 0 { + log.Printf("[DEBUG] Opensearch url not set. Setting to default") + opensearchUrl = "http://localhost:9200" + } + apiUrl := opensearchUrl + "/workflowexecution/_mapping" + log.Printf("[DEBUG] apiurl for fixing opensearch: %s", apiUrl) + // Create a new request req, err := http.NewRequest("PUT", apiUrl, bytes.NewBufferString(mapping)) if err != nil {