From 3e4a2d061c86f52ecbcdfc408995892dc31ffc33 Mon Sep 17 00:00:00 2001 From: Feroze Mohideen Date: Fri, 15 Sep 2023 16:57:56 -0400 Subject: [PATCH] fix bug where users are not able to delete environment variables from the front-end (#3583) --- api/server/handlers/porter_app/parse.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/api/server/handlers/porter_app/parse.go b/api/server/handlers/porter_app/parse.go index 01b77eddd4..f632854866 100644 --- a/api/server/handlers/porter_app/parse.go +++ b/api/server/handlers/porter_app/parse.go @@ -262,6 +262,23 @@ func buildUmbrellaChartValues( if existingValues != nil { if existingValues[helmName] != nil { existingValuesMap := existingValues[helmName].(map[string]interface{}) + if removeDeletedValues { + // strip the env variables before coalescing + if existingValuesMap["container"] != nil { + containerMap := existingValuesMap["container"].(map[string]interface{}) + if containerMap["env"] != nil { + envMap := containerMap["env"].(map[string]interface{}) + if envMap["normal"] != nil { + envMap["normal"] = make(map[string]interface{}) + } + if envMap["synced"] != nil { + envMap["synced"] = make([]map[string]interface{}, 0) + } + containerMap["env"] = envMap + } + existingValuesMap["container"] = containerMap + } + } helm_values = utils.DeepCoalesceValues(existingValuesMap, helm_values) } }