@@ -32,6 +32,7 @@ import (
32
32
"github.com/cortexlabs/cortex/pkg/operator/api/userconfig"
33
33
)
34
34
35
+ var MaxProjectSize = 1024 * 1024 * 50
35
36
var flagDeployForce bool
36
37
37
38
func init () {
@@ -51,7 +52,7 @@ var deployCmd = &cobra.Command{
51
52
52
53
func deploy (force bool , ignoreCache bool ) {
53
54
root := mustAppRoot ()
54
- _ , err := appNameFromConfig () // Check proper cortex.yaml
55
+ config , err := readConfig () // Check proper cortex.yaml
55
56
if err != nil {
56
57
errors .Exit (err )
57
58
}
@@ -66,34 +67,43 @@ func deploy(force bool, ignoreCache bool) {
66
67
errors .Exit (errors .Wrap (err , "cortex.yaml" , userconfig .ErrorReadConfig ().Error ()))
67
68
}
68
69
69
- projectPaths , err := files .ListDirRecursive (root , false ,
70
- files .IgnoreCortexYAML ,
71
- files .IgnoreHiddenFiles ,
72
- files .IgnoreHiddenFolders ,
73
- files .IgnorePythonGeneratedFiles ,
74
- )
75
- if err != nil {
76
- errors .Exit (err )
70
+ uploadBytes := map [string ][]byte {
71
+ "cortex.yaml" : configBytes ,
77
72
}
78
73
79
- projectZipBytes , err := zip .ToMem (& zip.Input {
80
- FileLists : []zip.FileListInput {
81
- {
82
- Sources : projectPaths ,
83
- RemovePrefix : root ,
74
+ if config .AreProjectFilesRequired () {
75
+ projectPaths , err := files .ListDirRecursive (root , false ,
76
+ files .IgnoreCortexYAML ,
77
+ files .IgnoreHiddenFiles ,
78
+ files .IgnoreHiddenFolders ,
79
+ files .IgnorePythonGeneratedFiles ,
80
+ )
81
+ if err != nil {
82
+ errors .Exit (err )
83
+ }
84
+
85
+ projectZipBytes , err := zip .ToMem (& zip.Input {
86
+ FileLists : []zip.FileListInput {
87
+ {
88
+ Sources : projectPaths ,
89
+ RemovePrefix : root ,
90
+ },
84
91
},
85
- },
86
- })
92
+ })
87
93
88
- if err != nil {
89
- errors .Exit (errors .Wrap (err , "failed to zip project folder" ))
94
+ if err != nil {
95
+ errors .Exit (errors .Wrap (err , "failed to zip project folder" ))
96
+ }
97
+
98
+ if len (projectZipBytes ) > MaxProjectSize {
99
+ errors .Exit (errors .New ("zipped project folder exceeds " + s .Int (MaxProjectSize ) + " bytes" ))
100
+ }
101
+
102
+ uploadBytes ["project.zip" ] = projectZipBytes
90
103
}
91
104
92
105
uploadInput := & HTTPUploadInput {
93
- Bytes : map [string ][]byte {
94
- "cortex.yaml" : configBytes ,
95
- "project.zip" : projectZipBytes ,
96
- },
106
+ Bytes : uploadBytes ,
97
107
}
98
108
99
109
response , err := HTTPUpload ("/deploy" , uploadInput , params )
0 commit comments