fix(web-console): zip invalid — Close() после Bytes() (v0.1.6)
This commit is contained in:
@@ -27,7 +27,7 @@ spec:
|
|||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: funcs
|
- name: funcs
|
||||||
image: naeel/sless-funcs-service:v0.1.5
|
image: naeel/sless-funcs-service:v0.1.6
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 8090
|
- containerPort: 8090
|
||||||
env:
|
env:
|
||||||
|
|||||||
+16
-13
@@ -605,16 +605,16 @@ func env(key, fallback string) string {
|
|||||||
// Принимает code (основной файл) + deps (requirements.txt / package.json).
|
// Принимает code (основной файл) + deps (requirements.txt / package.json).
|
||||||
func proxyCreateFunction(w http.ResponseWriter, r *http.Request, operatorURL, serviceToken, ns string) {
|
func proxyCreateFunction(w http.ResponseWriter, r *http.Request, operatorURL, serviceToken, ns string) {
|
||||||
var req struct {
|
var req struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Runtime string `json:"runtime"`
|
Runtime string `json:"runtime"`
|
||||||
Kind string `json:"kind"` // "service" | "function"; default "service"
|
Kind string `json:"kind"` // "service" | "function"; default "service"
|
||||||
Code string `json:"code"`
|
Code string `json:"code"`
|
||||||
Filename string `json:"filename"`
|
Filename string `json:"filename"`
|
||||||
Deps string `json:"deps"` // содержимое requirements.txt / package.json
|
Deps string `json:"deps"` // содержимое requirements.txt / package.json
|
||||||
DepsFile string `json:"deps_filename"` // "requirements.txt" или "package.json"
|
DepsFile string `json:"deps_filename"` // "requirements.txt" или "package.json"
|
||||||
Entrypoint string `json:"entrypoint"`
|
Entrypoint string `json:"entrypoint"`
|
||||||
MemoryMB int `json:"memory_mb"`
|
MemoryMB int `json:"memory_mb"`
|
||||||
TimeoutSec int `json:"timeout_sec"`
|
TimeoutSec int `json:"timeout_sec"`
|
||||||
}
|
}
|
||||||
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
|
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
|
||||||
http.Error(w, `{"error":"invalid JSON"}`, http.StatusBadRequest)
|
http.Error(w, `{"error":"invalid JSON"}`, http.StatusBadRequest)
|
||||||
@@ -699,8 +699,8 @@ func proxySaveFunction(w http.ResponseWriter, r *http.Request, operatorURL, serv
|
|||||||
var req struct {
|
var req struct {
|
||||||
Code string `json:"code"`
|
Code string `json:"code"`
|
||||||
Filename string `json:"filename"`
|
Filename string `json:"filename"`
|
||||||
Kind string `json:"kind"` // "function" | "service"
|
Kind string `json:"kind"` // "function" | "service"
|
||||||
Deps string `json:"deps"` // содержимое requirements.txt / package.json
|
Deps string `json:"deps"` // содержимое requirements.txt / package.json
|
||||||
DepsFile string `json:"deps_filename"` // имя файла зависимостей
|
DepsFile string `json:"deps_filename"` // имя файла зависимостей
|
||||||
}
|
}
|
||||||
if err := json.NewDecoder(r.Body).Decode(&req); err != nil || req.Code == "" || req.Filename == "" {
|
if err := json.NewDecoder(r.Body).Decode(&req); err != nil || req.Code == "" || req.Filename == "" {
|
||||||
@@ -774,7 +774,10 @@ func buildZipFiles(files map[string]string) ([]byte, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return buf.Bytes(), zw.Close()
|
if err := zw.Close(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return buf.Bytes(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// proxyFnStatus отдаёт текущий phase+url функции/сервиса — используется для UI polling.
|
// proxyFnStatus отдаёт текущий phase+url функции/сервиса — используется для UI polling.
|
||||||
|
|||||||
Reference in New Issue
Block a user