christophd commented on code in PR #17335:
URL: https://github.com/apache/camel/pull/17335#discussion_r1977456905


##########
dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/main/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/KubernetesDelete.java:
##########
@@ -17,93 +17,68 @@
 
 package org.apache.camel.dsl.jbang.core.commands.kubernetes;
 
-import java.io.File;
-import java.io.FileInputStream;
+import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 import io.fabric8.kubernetes.api.model.StatusDetails;
+import io.fabric8.openshift.client.OpenShiftClient;
 import org.apache.camel.dsl.jbang.core.commands.CamelJBangMain;
-import org.apache.camel.util.ObjectHelper;
+import org.apache.camel.dsl.jbang.core.commands.kubernetes.traits.BaseTrait;
 import org.apache.camel.util.StringHelper;
+import org.codehaus.plexus.util.ExceptionUtils;
 import picocli.CommandLine;
 
-@CommandLine.Command(name = "delete", description = "Delete Camel application 
from Kubernetes", sortOptions = false)
-public class KubernetesDelete extends KubernetesBaseCommand {
-
-    @CommandLine.Parameters(description = "The Camel file to delete. 
Integration name is derived from the file name.",
-                            arity = "0..1", paramLabel = "<file>")
-    String filePath;
+import static 
org.apache.camel.dsl.jbang.core.commands.kubernetes.KubernetesHelper.getKubernetesClient;
 
-    @CommandLine.Option(names = { "--working-dir" },
-                        description = "The working directory where to find 
exported project sources.")
-    String workingDir;
+@CommandLine.Command(name = "delete",
+                     description = "Delete Camel application from Kubernetes. 
This operation will delete all resources associated to this app, such as: 
Deployment, Routes, Services, etc. filtering by labels 
\"app.kubernetes.io/managed-by=camel-jbang\" and \"app=<app name>\".",
+                     sortOptions = false)
+public class KubernetesDelete extends KubernetesBaseCommand {
 
-    @CommandLine.Option(names = { "--cluster-type" },
-                        description = "The target cluster type. Special 
configurations may be applied to different cluster types such as Kind or 
Minikube or Openshift."
-                                      +
-                                      " If a target cluster type was set to 
create the project (run/export command), it needs to be set.")
-    protected String clusterType;
+    @CommandLine.Parameters(description = "The deployed application name", 
arity = "1", paramLabel = "<app name>")
+    String appName;
 
     public KubernetesDelete(CamelJBangMain main) {
         super(main);
-        projectNameSuppliers.add(() -> projectNameFromFilePath(() -> 
filePath));
     }
 
     public Integer doCall() throws Exception {
-
-        // First, try the explicit workingDir
-        File resolvedManifestDir = null;
-        if (workingDir != null) {
-            File resolvedWorkingDir = new File(workingDir);
-            File candidateDir = new File(resolvedWorkingDir, 
"target/kubernetes");
-            if (candidateDir.isDirectory()) {
-                resolvedManifestDir = candidateDir;
-            }
-        }
-
-        String projectName = getProjectName();
-
-        // Next, try the project name in the run dir
-        if (resolvedManifestDir == null) {
-            File resolvedWorkingDir = new File(RUN_PLATFORM_DIR + "/" + 
projectName);
-            File candidateDir = new File(resolvedWorkingDir, 
"target/kubernetes");
-            if (candidateDir.isDirectory()) {
-                resolvedManifestDir = candidateDir;
+        printer().printf("Deleting all resources from app: %s%n", appName);
+        Map<String, String> labels = new HashMap<>();
+        // this label is set in KubernetesRun command
+        labels.put(BaseTrait.KUBERNETES_LABEL_MANAGED_BY, "camel-jbang");
+        labels.put("app", appName);
+        List<StatusDetails> deleteStatuses = new ArrayList<>();
+        try {
+            // delete the most common resources

Review Comment:
   What about resources like Secret, ConfigMap and other resources that have 
been created as part of the Kubernetes export/run manifest?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@camel.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to