@@ -95,6 +95,7 @@ type DeployOptions struct {
95
95
files * deployFiles
96
96
functions * deployFiles
97
97
functionSchedules []* models.FunctionSchedule
98
+ functionsConfig map [string ]models.FunctionConfig
98
99
}
99
100
100
101
type uploadError struct {
@@ -225,7 +226,7 @@ func (n *Netlify) DoDeploy(ctx context.Context, options *DeployOptions, deploy *
225
226
226
227
options .files = files
227
228
228
- functions , schedules , err := bundle (ctx , options .FunctionsDir , options .Observer )
229
+ functions , schedules , functionsConfig , err := bundle (ctx , options .FunctionsDir , options .Observer )
229
230
if err != nil {
230
231
if options .Observer != nil {
231
232
options .Observer .OnFailedWalk ()
@@ -234,6 +235,7 @@ func (n *Netlify) DoDeploy(ctx context.Context, options *DeployOptions, deploy *
234
235
}
235
236
options .functions = functions
236
237
options .functionSchedules = schedules
238
+ options .functionsConfig = functionsConfig
237
239
238
240
deployFiles := & models.DeployFiles {
239
241
Files : options .files .Sums ,
@@ -255,11 +257,16 @@ func (n *Netlify) DoDeploy(ctx context.Context, options *DeployOptions, deploy *
255
257
deployFiles .FunctionSchedules = schedules
256
258
}
257
259
260
+ if options .functionsConfig != nil {
261
+ deployFiles .FunctionsConfig = options .functionsConfig
262
+ }
263
+
258
264
l := context .GetLogger (ctx )
259
265
l .WithFields (logrus.Fields {
260
266
"site_id" : options .SiteID ,
261
267
"deploy_files" : len (options .files .Sums ),
262
268
"scheduled_functions" : len (schedules ),
269
+ "functions_config" : functionsConfig ,
263
270
}).Debug ("Starting to deploy files" )
264
271
authInfo := context .GetAuthInfo (ctx )
265
272
@@ -649,9 +656,9 @@ func addEdgeFunctionsToDeployFiles(dir string, files *deployFiles, observer Depl
649
656
})
650
657
}
651
658
652
- func bundle (ctx context.Context , functionDir string , observer DeployObserver ) (* deployFiles , []* models.FunctionSchedule , error ) {
659
+ func bundle (ctx context.Context , functionDir string , observer DeployObserver ) (* deployFiles , []* models.FunctionSchedule , map [ string ]models. FunctionConfig , error ) {
653
660
if functionDir == "" {
654
- return nil , nil , nil
661
+ return nil , nil , nil , nil
655
662
}
656
663
657
664
manifestFile , err := os .Open (filepath .Join (functionDir , "manifest.json" ))
@@ -668,7 +675,7 @@ func bundle(ctx context.Context, functionDir string, observer DeployObserver) (*
668
675
669
676
info , err := ioutil .ReadDir (functionDir )
670
677
if err != nil {
671
- return nil , nil , err
678
+ return nil , nil , nil , err
672
679
}
673
680
674
681
for _ , i := range info {
@@ -678,23 +685,23 @@ func bundle(ctx context.Context, functionDir string, observer DeployObserver) (*
678
685
case zipFile (i ):
679
686
runtime , err := readZipRuntime (filePath )
680
687
if err != nil {
681
- return nil , nil , err
688
+ return nil , nil , nil , err
682
689
}
683
690
file , err := newFunctionFile (filePath , i , runtime , observer )
684
691
if err != nil {
685
- return nil , nil , err
692
+ return nil , nil , nil , err
686
693
}
687
694
functions .Add (file .Name , file )
688
695
case jsFile (i ):
689
696
file , err := newFunctionFile (filePath , i , jsRuntime , observer )
690
697
if err != nil {
691
- return nil , nil , err
698
+ return nil , nil , nil , err
692
699
}
693
700
functions .Add (file .Name , file )
694
701
case goFile (filePath , i , observer ):
695
702
file , err := newFunctionFile (filePath , i , goRuntime , observer )
696
703
if err != nil {
697
- return nil , nil , err
704
+ return nil , nil , nil , err
698
705
}
699
706
functions .Add (file .Name , file )
700
707
default :
@@ -704,14 +711,14 @@ func bundle(ctx context.Context, functionDir string, observer DeployObserver) (*
704
711
}
705
712
}
706
713
707
- return functions , nil , nil
714
+ return functions , nil , nil , nil
708
715
}
709
716
710
- func bundleFromManifest (ctx context.Context , manifestFile * os.File , observer DeployObserver ) (* deployFiles , []* models.FunctionSchedule , error ) {
717
+ func bundleFromManifest (ctx context.Context , manifestFile * os.File , observer DeployObserver ) (* deployFiles , []* models.FunctionSchedule , map [ string ]models. FunctionConfig , error ) {
711
718
manifestBytes , err := ioutil .ReadAll (manifestFile )
712
719
713
720
if err != nil {
714
- return nil , nil , err
721
+ return nil , nil , nil , err
715
722
}
716
723
717
724
logger := context .GetLogger (ctx )
@@ -722,23 +729,24 @@ func bundleFromManifest(ctx context.Context, manifestFile *os.File, observer Dep
722
729
err = json .Unmarshal (manifestBytes , & manifest )
723
730
724
731
if err != nil {
725
- return nil , nil , fmt .Errorf ("malformed functions manifest file: %w" , err )
732
+ return nil , nil , nil , fmt .Errorf ("malformed functions manifest file: %w" , err )
726
733
}
727
734
728
735
schedules := make ([]* models.FunctionSchedule , 0 , len (manifest .Functions ))
729
736
functions := newDeployFiles ()
737
+ functionsConfig := make (map [string ]models.FunctionConfig )
730
738
731
739
for _ , function := range manifest .Functions {
732
740
fileInfo , err := os .Stat (function .Path )
733
741
734
742
if err != nil {
735
- return nil , nil , fmt .Errorf ("manifest file specifies a function path that cannot be found: %s" , function .Path )
743
+ return nil , nil , nil , fmt .Errorf ("manifest file specifies a function path that cannot be found: %s" , function .Path )
736
744
}
737
745
738
746
file , err := newFunctionFile (function .Path , fileInfo , function .Runtime , observer )
739
747
740
748
if err != nil {
741
- return nil , nil , err
749
+ return nil , nil , nil , err
742
750
}
743
751
744
752
if function .Schedule != "" {
@@ -748,10 +756,16 @@ func bundleFromManifest(ctx context.Context, manifestFile *os.File, observer Dep
748
756
})
749
757
}
750
758
759
+ if function .DisplayName != "" {
760
+ functionsConfig [file .Name ] = models.FunctionConfig {
761
+ DisplayName : function .DisplayName ,
762
+ }
763
+ }
764
+
751
765
functions .Add (file .Name , file )
752
766
}
753
767
754
- return functions , schedules , nil
768
+ return functions , schedules , functionsConfig , nil
755
769
}
756
770
757
771
func readZipRuntime (filePath string ) (string , error ) {
0 commit comments