Forráskód Böngészése

Merge pull request #2060 from porter-dev/nico/por-471-job-chart-deletion-is-not-triggering

[POR-471] Job chart deletion is not triggering delete_application for env groups
Nicolas Frati 4 éve
szülő
commit
1581fad99e
1 módosított fájl, 26 hozzáadás és 0 törlés
  1. 26 0
      dashboard/src/shared/hooks/useChart.ts

+ 26 - 0
dashboard/src/shared/hooks/useChart.ts

@@ -101,6 +101,32 @@ export const useChart = (oldChart: ChartType, closeChart: () => void) => {
    */
   const deleteChart = async () => {
     try {
+      const syncedEnvGroups = chart.config?.container?.env?.synced || [];
+      const removeApplicationToEnvGroupPromises = syncedEnvGroups.map(
+        (envGroup: any) => {
+          return api.removeApplicationFromEnvGroup(
+            "<token>",
+            {
+              name: envGroup?.name,
+              app_name: chart.name,
+            },
+            {
+              project_id: currentProject.id,
+              cluster_id: currentCluster.id,
+              namespace: chart.namespace,
+            }
+          );
+        }
+      );
+      try {
+        await Promise.all(removeApplicationToEnvGroupPromises);
+      } catch (error) {
+        setCurrentError(
+          "We coudln't remove the synced env group from the application, please remove it manually before uninstalling the chart, or try again."
+        );
+        return;
+      }
+
       await api.uninstallTemplate(
         "<token>",
         {},