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
// NewClusterClientFromFile creates and returns the address of a clusterClient, the kubeconfigFile argument is expected to be the path to a
74
+
// NewClusterClientFromDefaultSearchPath creates and returns the address of a clusterClient, the kubeconfigFile argument is expected to be the path to a
@@ -34,20 +42,40 @@ var deleteClusterCmd = &cobra.Command{
34
42
Short: "Delete kubernetes cluster",
35
43
Long: `Delete a kubernetes cluster with one command`,
36
44
Run: func(cmd*cobra.Command, args []string) {
37
-
ifdo.ClusterName=="" {
38
-
exitWithHelp(cmd, "Please provide cluster name.")
39
-
}
40
45
iferr:=RunDelete(); err!=nil {
41
46
glog.Exit(err)
42
47
}
43
48
},
44
49
}
45
50
46
51
funcinit() {
52
+
deleteClusterCmd.Flags().StringVarP(&do.KubeconfigPath, "kubeconfig", "", "", "Path to the kubeconfig file to use for connecting to the cluster to be deleted, if empty, the default KUBECONFIG load path is used.")
47
53
deleteClusterCmd.Flags().StringVarP(&do.ProviderComponents, "provider-components", "p", "", "A yaml file containing cluster api provider controllers and supporting objects, if empty the value is loaded from the cluster's configuration store.")
54
+
// BindContextFlags will bind the flags cluster, namespace, and user
{"create cluster with no arguments with invalid flag", []string{"create", "cluster", "--invalid-flag"}, 1, "create-cluster-no-args-invalid-flag.golden"},
64
64
{"delete with no arguments", []string{"delete"}, 0, "delete-no-args.golden"},
65
65
{"delete with no arguments with invalid flag", []string{"delete", "--invalid-flag"}, 1, "delete-no-args-invalid-flag.golden"},
66
-
{"delete cluster with no arguments", []string{"delete", "cluster"}, 1, "delete-cluster-no-args.golden"},
67
66
{"delete cluster with no arguments with invalid flag", []string{"delete", "cluster", "--invalid-flag"}, 1, "delete-cluster-no-args-invalid-flag.golden"},
68
67
{"validate with no arguments", []string{"validate"}, 0, "validate-no-args.golden"},
69
68
{"validate with no arguments with invalid flag", []string{"validate", "--invalid-flag"}, 1, "validate-no-args-invalid-flag.golden"},
Copy file name to clipboardExpand all lines: clusterctl/testdata/delete-cluster-no-args-invalid-flag.golden
+4
Original file line number
Diff line number
Diff line change
@@ -3,8 +3,12 @@ Usage:
3
3
clusterctl delete cluster [flags]
4
4
5
5
Flags:
6
+
--cluster string The name of the kubeconfig cluster to use
6
7
-h, --help help for cluster
8
+
--kubeconfig string Path to the kubeconfig file to use for connecting to the cluster to be deleted, if empty, the default KUBECONFIG load path is used.
9
+
-n, --namespace string If present, the namespace scope for this CLI request
7
10
-p, --provider-components string A yaml file containing cluster api provider controllers and supporting objects, if empty the value is loaded from the cluster's configuration store.
11
+
--user string The name of the kubeconfig user to use
8
12
9
13
Global Flags:
10
14
--alsologtostderr log to standard error as well as files
// NewCoreClientSetForDefaultSearchPath creates a core kubernetes clientset. If the kubeconfigPath is specified then the configuration is loaded from that path.
31
36
// Otherwise the default kubeconfig search path is used.
@@ -48,8 +54,9 @@ func NewCoreClientSetForKubeconfig(kubeconfig string) (*kubernetes.Clientset, er
48
54
49
55
// NewClusterApiClientForDefaultSearchPath creates a Cluster API clientset. If the kubeconfigPath is specified then the configuration is loaded from that path.
50
56
// Otherwise the default kubeconfig search path is used.
// newRestConfigForDefaultSearchPath creates a rest.Config by searching for the kubeconfig on the default search path. If an override 'kubeconfigPath' is
106
106
// given then that path is used instead of the default path. If no override is given, an attempt is made to load the
107
107
// 'in cluster' config. If this fails, then the default search path is used.
// newApiConfigForDefaultSearchPath creates an api.Config by searching for the kubeconfig on the default search path. If an override 'kubeconfigPath' is
0 commit comments