Browse code

add --all-namespaces to export

deads2k authored on 2015/08/22 03:16:08
Showing 3 changed files
... ...
@@ -72,9 +72,7 @@ function cleanup()
72 72
 	oc get -n docker builds --output-version=v1beta3 -t '{{ range .items }}{{.metadata.name}}{{ "\n" }}{{end}}' | xargs -r -l oc build-logs -n docker >"${LOG_DIR}/dockerbuild.log"
73 73
 	oc get -n custom builds --output-version=v1beta3 -t '{{ range .items }}{{.metadata.name}}{{ "\n" }}{{end}}' | xargs -r -l oc build-logs -n custom >"${LOG_DIR}/custombuild.log"
74 74
 
75
-	oc export all --all -n test --raw > ${LOG_DIR}/export_all_test.json
76
-	oc export all --all -n docker --raw > ${LOG_DIR}/export_all_docker.json
77
-	oc export all --all -n custom --raw > ${LOG_DIR}/export_all_custom.json
75
+	oc export all --all --all-namespaces --raw -o json > ${LOG_DIR}/export_all.json
78 76
 
79 77
 	echo "[INFO] Dumping etcd contents to ${ARTIFACT_DIR}/etcd_dump.json"
80 78
 	set_curl_args 0 1
... ...
@@ -71,6 +71,7 @@ func NewCmdExport(fullName string, f *clientcmd.Factory, in io.Reader, out io.Wr
71 71
 	cmd.Flags().Bool("raw", false, "If true, do not alter the resources in any way after they are loaded.")
72 72
 	cmd.Flags().StringP("selector", "l", "", "Selector (label query) to filter on")
73 73
 	cmd.Flags().Bool("all", false, "Select all resources in the namespace of the specified resource types")
74
+	cmd.Flags().Bool("all-namespaces", false, "If present, list the requested object(s) across all namespaces. Namespace in current context is ignored even if specified with --namespace.")
74 75
 	cmd.Flags().VarP(&filenames, "filename", "f", "Filename, directory, or URL to file to use to edit the resource.")
75 76
 	cmdutil.AddPrinterFlags(cmd)
76 77
 	return cmd
... ...
@@ -79,6 +80,7 @@ func NewCmdExport(fullName string, f *clientcmd.Factory, in io.Reader, out io.Wr
79 79
 func RunExport(f *clientcmd.Factory, exporter Exporter, in io.Reader, out io.Writer, cmd *cobra.Command, args []string, filenames util.StringList) error {
80 80
 	selector := cmdutil.GetFlagString(cmd, "selector")
81 81
 	all := cmdutil.GetFlagBool(cmd, "all")
82
+	allNamespaces := cmdutil.GetFlagBool(cmd, "all-namespaces")
82 83
 	exact := cmdutil.GetFlagBool(cmd, "exact")
83 84
 	asTemplate := cmdutil.GetFlagString(cmd, "as-template")
84 85
 	raw := cmdutil.GetFlagBool(cmd, "raw")
... ...
@@ -99,7 +101,7 @@ func RunExport(f *clientcmd.Factory, exporter Exporter, in io.Reader, out io.Wri
99 99
 
100 100
 	mapper, typer := f.Object()
101 101
 	b := resource.NewBuilder(mapper, typer, f.ClientMapperForCommand()).
102
-		NamespaceParam(cmdNamespace).DefaultNamespace().
102
+		NamespaceParam(cmdNamespace).DefaultNamespace().AllNamespaces(allNamespaces).
103 103
 		FilenameParam(explicit, filenames...).
104 104
 		SelectorParam(selector).
105 105
 		ResourceTypeOrNameArgs(all, args...).
... ...
@@ -8,6 +8,8 @@ set -o pipefail
8 8
 
9 9
 oc new-app -f examples/sample-app/application-template-stibuild.json --name=sample
10 10
 
11
+oc export all --all --all-namespaces --exact
12
+
11 13
 [ "$(oc export svc --all -t '{{range .items}}{{.metadata.name}}{{"\n"}}{{end}}' | wc -l)" -ne 0 ]
12 14
 [ "$(oc export svc --all --as-template=template | grep 'kind: Template')" ]
13 15
 [ ! "$(oc export svc --all | grep 'clusterIP')" ]