diff --git a/console/deploy/console.yaml b/console/deploy/console.yaml index 80e1387..b60330e 100644 --- a/console/deploy/console.yaml +++ b/console/deploy/console.yaml @@ -52,7 +52,7 @@ spec: serviceAccountName: fission-console containers: - name: console - image: naeel/fission-console:v1.3.53 + image: naeel/fission-console:v1.3.54 imagePullPolicy: Always ports: - containerPort: 8090 diff --git a/console/internal/api/lint_archive.go b/console/internal/api/lint_archive.go index 150ee83..49f538d 100644 --- a/console/internal/api/lint_archive.go +++ b/console/internal/api/lint_archive.go @@ -60,6 +60,8 @@ func (s *Server) handleLintArchive(w http.ResponseWriter, r *http.Request) { // Опциональный entrypoint для проверки наличия файла в архиве (формат: "module.function") entrypoint := strings.TrimSpace(r.FormValue("entrypoint")) + // Опциональный язык для проверки соответствия файлов в архиве + selectedLang := strings.ToLower(strings.TrimSpace(r.FormValue("language"))) f, _, err := r.FormFile("archive") if err != nil { @@ -199,6 +201,44 @@ func (s *Server) handleLintArchive(w http.ResponseWriter, r *http.Request) { return } + // Проверяем соответствие выбранного языка файлам в архиве + if selectedLang != "" { + langExt := map[string]string{ + "python": ".py", "python3": ".py", + "node.js": ".js", "nodejs": ".js", "javascript": ".js", "node": ".js", + "ruby": ".rb", + "php": ".php", + "go": ".go", + "perl": ".pl", + } + expectedExt, known := langExt[selectedLang] + if known { + // Собираем расширения файлов в архиве + extCount := map[string]int{} + for _, zf := range zr.File { + if !zf.FileInfo().IsDir() { + ext := strings.ToLower(filepath.Ext(zf.Name)) + if ext != "" { + extCount[ext]++ + } + } + } + // Если нет ни одного файла с ожидаемым расширением — предупреждение + if extCount[expectedExt] == 0 { + found := []string{} + for ext := range extCount { + found = append(found, ext) + } + results = append(results, lintResult{ + File: "язык", + OK: false, + Output: fmt.Sprintf("выбран язык '%s' (ожидается %s), но в архиве таких файлов нет (найдено: %s)", selectedLang, expectedExt, strings.Join(found, ", ")), + }) + hasError = true + } + } + } + // Проверяем entrypoint: формат "module.function" → файл "module.py" должен быть в архиве if entrypoint != "" { parts := strings.SplitN(entrypoint, ".", 2) diff --git a/console/ui/index.html b/console/ui/index.html index ed0d80d..4adb451 100644 --- a/console/ui/index.html +++ b/console/ui/index.html @@ -102,7 +102,7 @@