@@ -61,7 +61,7 @@ func runApplyCommandE(command *cobra.Command, _ []string) error {
61
61
if os .Getuid () == 0 {
62
62
return fmt .Errorf ("do not run this tool as root, or on your server. Run it from your own client remotely" )
63
63
}
64
-
64
+
65
65
files , err := command .Flags ().GetStringArray ("file" )
66
66
if err != nil {
67
67
return err
@@ -97,7 +97,7 @@ func runApplyCommandE(command *cobra.Command, _ []string) error {
97
97
}
98
98
99
99
plan := types.Plan {}
100
- if err := yaml .Unmarshal (yamlBytes , & plan );err != nil {
100
+ if err := yaml .Unmarshal (yamlBytes , & plan ); err != nil {
101
101
return fmt .Errorf ("unmarshal of --file %s gave error: %s" , yamlFile , err .Error ())
102
102
}
103
103
@@ -304,6 +304,9 @@ func process(plan types.Plan, prefs InstallPreferences) error {
304
304
return errors .Wrap (err , "getS3Credentials" )
305
305
}
306
306
307
+ if len (accessKey ) == 0 || len (secretKey ) == 0 {
308
+ return fmt .Errorf ("S3 secrets returned from getS3Credentials were empty, but should have been generated" )
309
+ }
307
310
if err := installMinio (accessKey , secretKey ); err != nil {
308
311
return errors .Wrap (err , "installMinio" )
309
312
}
@@ -575,19 +578,27 @@ func installOpenfaas(scaleToZero, ingressOperator bool) error {
575
578
}
576
579
577
580
func getS3Credentials () (string , string , error ) {
578
- args := []string {"get" , "secret" , "-n" , "openfaas-fn" , "s3-access-key" , "-o jsonpath=' {.data.s3-access-key}' " }
581
+ args := []string {"get" , "secret" , "-n" , "openfaas-fn" , "s3-access-key" , "-o" , " jsonpath={.data.s3-access-key}" }
579
582
res , err := k8s .KubectlTask (args ... )
580
583
if err != nil {
581
584
return "" , "" , err
582
585
}
586
+ if res .ExitCode != 0 {
587
+ return "" , "" , fmt .Errorf ("error getting s3 secret %s / %s" , res .Stderr , res .Stdout )
588
+ }
589
+
583
590
decoded , _ := b64 .StdEncoding .DecodeString (res .Stdout )
584
591
accessKey := decoded
585
592
586
- args = []string {"get" , "secret" , "-n" , "openfaas-fn" , "s3-secret-key" , "-o jsonpath=' {.data.s3-secret-key}' " }
593
+ args = []string {"get" , "secret" , "-n" , "openfaas-fn" , "s3-secret-key" , "-o" , " jsonpath={.data.s3-secret-key}" }
587
594
res , err = k8s .KubectlTask (args ... )
588
595
if err != nil {
589
596
return "" , "" , err
590
597
}
598
+ if res .ExitCode != 0 {
599
+ return "" , "" , fmt .Errorf ("error getting s3 secret %s / %s" , res .Stderr , res .Stdout )
600
+ }
601
+
591
602
decoded , _ = b64 .StdEncoding .DecodeString (res .Stdout )
592
603
secretKey := decoded
593
604
@@ -606,8 +617,8 @@ func installMinio(accessKey, secretKey string) error {
606
617
"--set service.port=9000" ,
607
618
"--set service.type=ClusterIP" ,
608
619
"--set resources.requests.memory=512Mi" ,
609
- "--secret-key=" + secretKey ,
610
620
"--access-key=" + accessKey ,
621
+ "--secret-key=" + secretKey ,
611
622
"--wait" ,
612
623
}
613
624
0 commit comments