Repository: kestra-io/kestra
Issue: Set delete to false for the deploy action and `flow namespace update` CLI 

### Feature description

Deleting flows by default is too dangerous, it should be set to false by default

I could submit a PR to just set this to true by default here: https://github.com/kestra-io/kestra/blob/c2822aeea118473ddbeace8919f50e4fbbc802f7/cli/src/main/java/io/kestra/cli/commands/AbstractServiceNamespaceUpdateCommand.java#L16

but @tchiotludo mentioned it's cleaner to rewrite this to have "delete=false" (I agree)

the action needs to be adjusted as well https://github.com/kestra-io/deploy-action 

Issue comments:

Pull request review comments:

Patch that resolved the issue:
diff --git a/cli/src/main/java/io/kestra/cli/commands/AbstractServiceNamespaceUpdateCommand.java b/cli/src/main/java/io/kestra/cli/commands/AbstractServiceNamespaceUpdateCommand.java
index 3964e7efec..4337888f76 100644
--- a/cli/src/main/java/io/kestra/cli/commands/AbstractServiceNamespaceUpdateCommand.java
+++ b/cli/src/main/java/io/kestra/cli/commands/AbstractServiceNamespaceUpdateCommand.java
@@ -14,8 +14,8 @@ public abstract class AbstractServiceNamespaceUpdateCommand extends AbstractApiC
     @CommandLine.Parameters(index = "1", description = "the directory containing files for current namespace")
     public Path directory;
 
-    @CommandLine.Option(names = {"--no-delete"}, description = "if missing should not be deleted")
-    public boolean noDelete = false ;
+    @CommandLine.Option(names = {"--delete"}, negatable = true, description = "if missing should be deleted")
+    public boolean delete = false;
 
     @Builder
     @Value
diff --git a/cli/src/main/java/io/kestra/cli/commands/flows/namespaces/FlowNamespaceUpdateCommand.java b/cli/src/main/java/io/kestra/cli/commands/flows/namespaces/FlowNamespaceUpdateCommand.java
index 410c3f19cb..a8dfd0a5fe 100644
--- a/cli/src/main/java/io/kestra/cli/commands/flows/namespaces/FlowNamespaceUpdateCommand.java
+++ b/cli/src/main/java/io/kestra/cli/commands/flows/namespaces/FlowNamespaceUpdateCommand.java
@@ -57,7 +57,7 @@ public Integer call() throws Exception {
             }
             try(DefaultHttpClient client = client()) {
                 MutableHttpRequest<String> request = HttpRequest
-                    .POST("/api/v1/flows/" + namespace + "?delete=" + !noDelete, body).contentType(MediaType.APPLICATION_YAML);
+                    .POST("/api/v1/flows/" + namespace + "?delete=" + delete, body).contentType(MediaType.APPLICATION_YAML);
 
                 List<UpdateResult> updated = client.toBlocking().retrieve(
                     this.requestOptions(request),
diff --git a/cli/src/main/java/io/kestra/cli/commands/templates/namespaces/TemplateNamespaceUpdateCommand.java b/cli/src/main/java/io/kestra/cli/commands/templates/namespaces/TemplateNamespaceUpdateCommand.java
index 19e4777b50..a5c9126323 100644
--- a/cli/src/main/java/io/kestra/cli/commands/templates/namespaces/TemplateNamespaceUpdateCommand.java
+++ b/cli/src/main/java/io/kestra/cli/commands/templates/namespaces/TemplateNamespaceUpdateCommand.java
@@ -45,7 +45,7 @@ public Integer call() throws Exception {
 
             try (DefaultHttpClient client = client()) {
                 MutableHttpRequest<List<Template>> request = HttpRequest
-                    .POST("/api/v1/templates/" + namespace + "?delete=" + !noDelete, templates);
+                    .POST("/api/v1/templates/" + namespace + "?delete=" + delete, templates);
 
                 List<UpdateResult> updated = client.toBlocking().retrieve(
                     this.requestOptions(request),


Test patch:
diff --git a/cli/src/test/java/io/kestra/cli/commands/flows/namespaces/FlowNamespaceUpdateCommandTest.java b/cli/src/test/java/io/kestra/cli/commands/flows/namespaces/FlowNamespaceUpdateCommandTest.java
index 24f9327192..3437a90dc1 100644
--- a/cli/src/test/java/io/kestra/cli/commands/flows/namespaces/FlowNamespaceUpdateCommandTest.java
+++ b/cli/src/test/java/io/kestra/cli/commands/flows/namespaces/FlowNamespaceUpdateCommandTest.java
@@ -16,10 +16,11 @@
 
 class FlowNamespaceUpdateCommandTest {
     @Test
-    void run()  {
+    void runWithDelete()  {
         URL directory = FlowNamespaceUpdateCommandTest.class.getClassLoader().getResource("flows");
         ByteArrayOutputStream out = new ByteArrayOutputStream();
         System.setOut(new PrintStream(out));
+        URL subDirectory = FlowNamespaceUpdateCommandTest.class.getClassLoader().getResource("flows/flowsSubFolder");
 
         try (ApplicationContext ctx = ApplicationContext.run(Environment.CLI, Environment.TEST)) {
 
@@ -31,12 +32,28 @@ void run()  {
                 embeddedServer.getURL().toString(),
                 "--user",
                 "myuser:pass:word",
+                "--delete",
                 "io.kestra.cli",
                 directory.getPath(),
+            };
+            PicocliRunner.call(FlowNamespaceUpdateCommand.class, ctx, args);
+
+            assertThat(out.toString(), containsString("3 flow(s)"));
+            out.reset();
+
+            args = new String[]{
+                "--server",
+                embeddedServer.getURL().toString(),
+                "--user",
+                "myuser:pass:word",
+                "--delete",
+                "io.kestra.cli",
+                subDirectory.getPath(),
 
             };
             PicocliRunner.call(FlowNamespaceUpdateCommand.class, ctx, args);
 
+            // 2 delete + 1 update
             assertThat(out.toString(), containsString("3 flow(s)"));
         }
     }
@@ -94,17 +111,32 @@ void runNoDelete()  {
             PicocliRunner.call(FlowNamespaceUpdateCommand.class, ctx, args);
 
             assertThat(out.toString(), containsString("3 flow(s)"));
+            out.reset();
 
-            String[] newArgs = {
+            // no "delete" arg should behave as no-delete
+            args = new String[]{
                 "--server",
                 embeddedServer.getURL().toString(),
                 "--user",
                 "myuser:pass:word",
                 "io.kestra.cli",
-                subDirectory.getPath(),
-                "--no-delete"
+                subDirectory.getPath()
+            };
+            PicocliRunner.call(FlowNamespaceUpdateCommand.class, ctx, args);
+
+            assertThat(out.toString(), containsString("1 flow(s)"));
+            out.reset();
+
+            args = new String[]{
+                "--server",
+                embeddedServer.getURL().toString(),
+                "--user",
+                "myuser:pass:word",
+                "--no-delete",
+                "io.kestra.cli",
+                subDirectory.getPath()
             };
-            PicocliRunner.call(FlowNamespaceUpdateCommand.class, ctx, newArgs);
+            PicocliRunner.call(FlowNamespaceUpdateCommand.class, ctx, args);
 
             assertThat(out.toString(), containsString("1 flow(s)"));
         }