@@ -62,6 +62,10 @@ type DeployObserver interface {
62
62
OnFailedUpload (* FileBundle )
63
63
}
64
64
65
+ type DeployWarner interface {
66
+ OnWalkWarning (path , msg string )
67
+ }
68
+
65
69
// DeployOptions holds the option for creating a new deploy
66
70
type DeployOptions struct {
67
71
SiteID string
@@ -579,12 +583,16 @@ func bundle(functionDir string, observer DeployObserver) (*deployFiles, error) {
579
583
return nil , err
580
584
}
581
585
functions .Add (file .Name , file )
582
- case goFile (filePath , i ):
586
+ case goFile (filePath , i , observer ):
583
587
file , err := newFunctionFile (filePath , i , goRuntime , observer )
584
588
if err != nil {
585
589
return nil , err
586
590
}
587
591
functions .Add (file .Name , file )
592
+ default :
593
+ if warner , ok := observer .(DeployWarner ); ok {
594
+ warner .OnWalkWarning (filePath , "Function is not valid for deployment. Please check that it matches the format for the runtime." )
595
+ }
588
596
}
589
597
}
590
598
@@ -653,17 +661,31 @@ func jsFile(i os.FileInfo) bool {
653
661
return filepath .Ext (i .Name ()) == ".js"
654
662
}
655
663
656
- func goFile (filePath string , i os.FileInfo ) bool {
664
+ func goFile (filePath string , i os.FileInfo , observer DeployObserver ) bool {
665
+ warner , hasWarner := observer .(DeployWarner )
666
+
657
667
if m := i .Mode (); m & 0111 == 0 { // check if it's an executable file
668
+ if hasWarner {
669
+ warner .OnWalkWarning (filePath , "Go binary does not have executable permissions" )
670
+ }
658
671
return false
659
672
}
660
673
661
674
if _ , err := elf .Open (filePath ); err != nil { // check if it's a linux executable
675
+ if hasWarner {
676
+ warner .OnWalkWarning (filePath , "Go binary is not a linux executable" )
677
+ }
662
678
return false
663
679
}
664
680
665
681
v , err := version .ReadExe (filePath )
666
- return err == nil && strings .HasPrefix (v .Release , "go1." )
682
+ if err != nil || ! strings .HasPrefix (v .Release , "go1." ) {
683
+ if hasWarner {
684
+ warner .OnWalkWarning (filePath , "Unable to detect Go version 1.x" )
685
+ }
686
+ }
687
+
688
+ return true
667
689
}
668
690
669
691
func ignoreFile (rel string ) bool {
0 commit comments