Merge "Upgrade to helm3"
diff --git a/rapp-manager/src/main/java/org/oransc/rappmanager/helm/HelmClient.java b/rapp-manager/src/main/java/org/oransc/rappmanager/helm/HelmClient.java
index 64cb0f6..bfdb439 100644
--- a/rapp-manager/src/main/java/org/oransc/rappmanager/helm/HelmClient.java
+++ b/rapp-manager/src/main/java/org/oransc/rappmanager/helm/HelmClient.java
@@ -40,13 +40,17 @@
     }
 
     public void installApp(App app) throws ServiceException {
-        ProcessBuilder builder = prepareInstallCommand(app);
+        ProcessBuilder builder = prepareCreateNamespaceCommand(app.getNamespace());
+        executeCommand(builder);
+        builder = prepareInstallCommand(app);
         executeCommand(builder);
     }
 
     public void uninstallApp(App app) throws ServiceException {
         ProcessBuilder builder = prepareUnInstallCommand(app);
         executeCommand(builder);
+        builder = prepareDeleteNamespaceCommand(app.getNamespace());
+        executeCommand(builder);
     }
 
     protected String getOverrideFileName(App app) {
@@ -85,8 +89,8 @@
 
         List<String> helmArguments = Arrays.asList(//
             "helm", //
-            "install", getChartFileName(app), //
-            "--name", releaseName(app), //
+            "install", app.getName(), getChartFileName(app), //
+            "--version", app.getVersion(), //
             "--namespace", app.getNamespace(), //
             "--values", getOverrideFileName(app));
 
@@ -96,7 +100,19 @@
     }
 
     public ProcessBuilder prepareUnInstallCommand(App app) {
-        return new ProcessBuilder("helm", "delete", releaseName(app), "--purge");
+        return new ProcessBuilder("helm", "delete", app.getName(), "--namespace", app.getNamespace());
+    }
+
+    // Assuming to have a separate namespace for each App,
+    // modifications needed if multiple Apps could share the same namespace
+    public ProcessBuilder prepareCreateNamespaceCommand(String namespace) {
+        return new ProcessBuilder(Arrays.asList(//
+            "kubectl", "create", "namespace", namespace));
+    }
+
+    public ProcessBuilder prepareDeleteNamespaceCommand(String namespace) {
+        return new ProcessBuilder(Arrays.asList(//
+            "kubectl", "delete", "namespace", namespace, "--wait=false"));
     }
 
     private void addKubeApiInfo(List<String> helmArguments) {
diff --git a/rapp-manager/src/test/java/org/oransc/rappmanager/controller/KubernetesTest.java b/rapp-manager/src/test/java/org/oransc/rappmanager/controller/KubernetesTest.java
index 67b96c7..d47461a 100644
--- a/rapp-manager/src/test/java/org/oransc/rappmanager/controller/KubernetesTest.java
+++ b/rapp-manager/src/test/java/org/oransc/rappmanager/controller/KubernetesTest.java
@@ -84,8 +84,20 @@
 
         @Override
         public ProcessBuilder prepareUnInstallCommand(App app) {
-            String unistall = toString(super.prepareUnInstallCommand(app));
-            return executeInVagrant(unistall);
+            String uninstallCommand = toString(super.prepareUnInstallCommand(app));
+            return executeInVagrant(uninstallCommand);
+        }
+
+        @Override
+        public ProcessBuilder prepareCreateNamespaceCommand(String namespace) {
+            String createCommand = toString(super.prepareCreateNamespaceCommand(namespace));
+            return executeInVagrant(createCommand);
+        }
+
+        @Override
+        public ProcessBuilder prepareDeleteNamespaceCommand(String namespace) {
+            String deleteCommand = toString(super.prepareDeleteNamespaceCommand(namespace));
+            return executeInVagrant(deleteCommand);
         }
 
         private ProcessBuilder executeInVagrant(String command) {