diff --git a/console/deploy/console.yaml b/console/deploy/console.yaml index c59ecee..80e1387 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.52 + image: naeel/fission-console:v1.3.53 imagePullPolicy: Always ports: - containerPort: 8090 diff --git a/console/internal/api/lint_archive.go b/console/internal/api/lint_archive.go index 3ddb663..150ee83 100644 --- a/console/internal/api/lint_archive.go +++ b/console/internal/api/lint_archive.go @@ -58,6 +58,9 @@ func (s *Server) handleLintArchive(w http.ResponseWriter, r *http.Request) { return } + // Опциональный entrypoint для проверки наличия файла в архиве (формат: "module.function") + entrypoint := strings.TrimSpace(r.FormValue("entrypoint")) + f, _, err := r.FormFile("archive") if err != nil { writeJSONError(w, http.StatusBadRequest, "поле 'archive' обязательно") @@ -196,6 +199,60 @@ func (s *Server) handleLintArchive(w http.ResponseWriter, r *http.Request) { return } + // Проверяем entrypoint: формат "module.function" → файл "module.py" должен быть в архиве + if entrypoint != "" { + parts := strings.SplitN(entrypoint, ".", 2) + if len(parts) == 2 { + module := parts[0] + funcName := parts[1] + // Ищем файл module.py в архиве (поддерживаем вложенные пути) + foundFile := false + funcDefined := false + for _, zf := range zr.File { + base := strings.TrimSuffix(filepath.Base(zf.Name), ".py") + if base == module && strings.HasSuffix(zf.Name, ".py") { + foundFile = true + // Читаем содержимое и ищем определение функции + rc, openErr := zf.Open() + if openErr == nil { + var content bytes.Buffer + content.ReadFrom(rc) //nolint:errcheck + rc.Close() + for _, line := range strings.Split(content.String(), "\n") { + trimmed := strings.TrimSpace(line) + if strings.HasPrefix(trimmed, "def "+funcName+"(") || trimmed == "def "+funcName+":" { + funcDefined = true + break + } + } + } + break + } + } + if !foundFile { + results = append(results, lintResult{ + File: entrypoint, + OK: false, + Output: fmt.Sprintf("файл '%s.py' не найден в архиве — проверьте Entrypoint", module), + }) + hasError = true + } else if !funcDefined { + results = append(results, lintResult{ + File: entrypoint, + OK: false, + Output: fmt.Sprintf("функция '%s' не найдена в '%s.py' — проверьте Entrypoint", funcName, module), + }) + hasError = true + } else { + results = append(results, lintResult{ + File: entrypoint, + OK: true, + Output: fmt.Sprintf("entrypoint '%s' найден", entrypoint), + }) + } + } + } + w.Header().Set("Content-Type", "application/json") json.NewEncoder(w).Encode(map[string]any{ "ok": !hasError, diff --git a/console/ui/index.html b/console/ui/index.html index 00fca81..ed0d80d 100644 --- a/console/ui/index.html +++ b/console/ui/index.html @@ -102,7 +102,7 @@