Browse code

check that dest exists before attempting to extract

juanvallejo authored on 2016/07/30 06:17:22
Showing 2 changed files
... ...
@@ -102,6 +102,10 @@ func (o *ExtractOptions) Complete(f *clientcmd.Factory, in io.Reader, out io.Wri
102 102
 }
103 103
 
104 104
 func (o *ExtractOptions) Validate() error {
105
+	// determine if output location is valid before continuing
106
+	if _, err := os.Stat(o.TargetDirectory); err != nil {
107
+		return err
108
+	}
105 109
 	return nil
106 110
 }
107 111
 
... ...
@@ -44,6 +44,7 @@ os::cmd::expect_failure_and_text "oc extract secret/dockercfg secret/dockercfg -
44 44
 os::cmd::expect_success_and_text "oc extract secret/dockercfg secret/dockercfg --to '${workingdir}' --confirm" '.dockercfg'
45 45
 os::cmd::expect_success_and_text "oc extract secret/dockercfg --to '${workingdir}' --confirm" '.dockercfg'
46 46
 os::cmd::expect_success "oc extract secret/dockercfg --to '${workingdir}' --confirm | xargs rm"
47
+os::cmd::expect_failure_and_text "oc extract secret/dockercfg --to missing-dir" "stat missing-dir: no such file or directory"
47 48
 
48 49
 # attach secrets to service account
49 50
 # single secret with prefix