You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: cmd/delete.go
+63-55Lines changed: 63 additions & 55 deletions
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,6 @@ package cmd
2
2
3
3
import (
4
4
"fmt"
5
-
6
5
"github.com/ory/viper"
7
6
"github.com/spf13/cobra"
8
7
@@ -13,80 +12,89 @@ import (
13
12
14
13
funcinit() {
15
14
root.AddCommand(deleteCmd)
16
-
deleteCmd.Flags().BoolP("confirm", "c", false, "Prompt to confirm all configuration options (Env: $FUNC_CONFIRM)")
17
-
deleteCmd.Flags().StringP("path", "p", cwd(), "Path to the function project that should be undeployed (Env: $FUNC_PATH)")
18
-
deleteCmd.Flags().StringP("namespace", "n", "", "Namespace of the function to undeploy. By default, the namespace in func.yaml is used or the actual active namespace if not set in the configuration. (Env: $FUNC_NAMESPACE)")
// Initialize func with explicit name (when provided)
45
+
iflen(args) >0&&args[0] !="" {
46
+
pathChanged:=cmd.Flags().Changed("path")
47
+
ifpathChanged {
48
+
returnfmt.Errorf("Only one of --path and [NAME] should be provided")
49
+
}
50
+
function= fn.Function{
51
+
Name: args[0],
52
+
}
53
+
} else {
54
+
function, err=fn.NewFunction(config.Path)
55
+
iferr!=nil {
56
+
return
57
+
}
58
+
59
+
// Check if the Function has been initialized
60
+
if!function.Initialized() {
61
+
returnfmt.Errorf("the given path '%v' does not contain an initialized function", config.Path)
62
+
}
63
+
}
64
+
65
+
ns:=config.Namespace
66
+
ifns=="" {
67
+
ns=function.Namespace
68
+
}
69
+
70
+
remover, err:=newRemover(ns, config.Verbose)
71
+
iferr!=nil {
72
+
return
73
+
}
74
+
75
+
client:=fn.New(
76
+
fn.WithVerbose(config.Verbose),
77
+
fn.WithRemover(remover))
78
+
79
+
returnclient.Remove(cmd.Context(), function)
80
+
},
70
81
}
71
82
72
-
ns:=config.Namespace
73
-
ifns=="" {
74
-
ns=function.Namespace
75
-
}
83
+
delCmd.Flags().BoolP("confirm", "c", false, "Prompt to confirm all configuration options (Env: $FUNC_CONFIRM)")
84
+
delCmd.Flags().StringP("path", "p", cwd(), "Path to the function project that should be undeployed (Env: $FUNC_PATH)")
85
+
delCmd.Flags().StringP("namespace", "n", "", "Namespace of the function to undeploy. By default, the namespace in func.yaml is used or the actual active namespace if not set in the configuration. (Env: $FUNC_NAMESPACE)")
0 commit comments