@@ -49,11 +49,13 @@ const (
4949
5050var installDirs = []string {"node_modules/" , "bower_components/" }
5151
52- type uploadType int
53- type pointerData struct {
54- SHA string
55- Size int64
56- }
52+ type (
53+ uploadType int
54+ pointerData struct {
55+ SHA string
56+ Size int64
57+ }
58+ )
5759
5860type DeployObserver interface {
5961 OnSetupWalk () error
@@ -74,6 +76,12 @@ type DeployWarner interface {
7476 OnWalkWarning (path , msg string )
7577}
7678
79+ type DeployEnvironmentVariable struct {
80+ Key string
81+ Value string
82+ IsSecret bool
83+ }
84+
7785// DeployOptions holds the option for creating a new deploy
7886type DeployOptions struct {
7987 SiteID string
@@ -83,6 +91,7 @@ type DeployOptions struct {
8391 EdgeRedirectsDir string
8492 BuildDir string
8593 LargeMediaEnabled bool
94+ Environment []* models.DeployEnvironmentVariable
8695
8796 IsDraft bool
8897 SkipRetry bool
@@ -270,6 +279,10 @@ func (n *Netlify) DoDeploy(ctx context.Context, options *DeployOptions, deploy *
270279 deployFiles .Functions = options .functions .Sums
271280 }
272281
282+ if len (options .Environment ) > 0 {
283+ deployFiles .Environment = options .Environment
284+ }
285+
273286 if options .Observer != nil {
274287 if err := options .Observer .OnSuccessfulWalk (deployFiles ); err != nil {
275288 return nil , err
@@ -763,7 +776,6 @@ func bundle(ctx context.Context, functionDir string, observer DeployObserver) (*
763776
764777func bundleFromManifest (ctx context.Context , manifestFile * os.File , observer DeployObserver ) (* deployFiles , []* models.FunctionSchedule , map [string ]models.FunctionConfig , error ) {
765778 manifestBytes , err := ioutil .ReadAll (manifestFile )
766-
767779 if err != nil {
768780 return nil , nil , nil , err
769781 }
@@ -774,7 +786,6 @@ func bundleFromManifest(ctx context.Context, manifestFile *os.File, observer Dep
774786 var manifest functionsManifest
775787
776788 err = json .Unmarshal (manifestBytes , & manifest )
777-
778789 if err != nil {
779790 return nil , nil , nil , fmt .Errorf ("malformed functions manifest file: %w" , err )
780791 }
@@ -785,7 +796,6 @@ func bundleFromManifest(ctx context.Context, manifestFile *os.File, observer Dep
785796
786797 for _ , function := range manifest .Functions {
787798 fileInfo , err := os .Stat (function .Path )
788-
789799 if err != nil {
790800 return nil , nil , nil , fmt .Errorf ("manifest file specifies a function path that cannot be found: %s" , function .Path )
791801 }
@@ -802,7 +812,6 @@ func bundleFromManifest(ctx context.Context, manifestFile *os.File, observer Dep
802812 Timeout : function .Timeout ,
803813 }
804814 file , err := newFunctionFile (function .Path , fileInfo , runtime , & meta , observer )
805-
806815 if err != nil {
807816 return nil , nil , nil , err
808817 }
@@ -974,7 +983,7 @@ func jsFile(i os.FileInfo) bool {
974983func goFile (filePath string , i os.FileInfo , observer DeployObserver ) bool {
975984 warner , hasWarner := observer .(DeployWarner )
976985
977- if m := i .Mode (); m & 0111 == 0 && runtime .GOOS != "windows" { // check if it's an executable file. skip on windows, since it doesn't have that mode
986+ if m := i .Mode (); m & 0o111 == 0 && runtime .GOOS != "windows" { // check if it's an executable file. skip on windows, since it doesn't have that mode
978987 if hasWarner {
979988 warner .OnWalkWarning (filePath , "Go binary does not have executable permissions" )
980989 }
@@ -1016,8 +1025,8 @@ func ignoreFile(rel string, ignoreInstallDirs bool) bool {
10161025func createHeader (archive * zip.Writer , i os.FileInfo , runtime string ) (io.Writer , error ) {
10171026 if runtime == goRuntime || runtime == amazonLinux2 {
10181027 return archive .CreateHeader (& zip.FileHeader {
1019- CreatorVersion : 3 << 8 , // indicates Unix
1020- ExternalAttrs : 0777 << 16 , // -rwxrwxrwx file permissions
1028+ CreatorVersion : 3 << 8 , // indicates Unix
1029+ ExternalAttrs : 0o777 << 16 , // -rwxrwxrwx file permissions
10211030
10221031 // we need to make sure we don't have two ZIP files with the exact same contents - otherwise, our upload deduplication mechanism will do weird things.
10231032 // adding in the function name as a comment ensures that every function ZIP is unique
0 commit comments