pre-golang-removal: snapshot before removing all golang integration (2026-05-01)

This commit is contained in:
Naeel
2026-05-01 11:42:24 +03:00
parent f1b0369737
commit 2b97a3dbc6
11 changed files with 970 additions and 32 deletions
+7 -4
View File
@@ -24,7 +24,7 @@ import (
//
// Декодирование: если данные — валидный UTF-8, возвращаем как есть.
// Если это zip — ищем известные файлы (main.py, handler.rb и т.д.).
func extractPackageSourceCode(ctx context.Context, s *Server, pkg *unstructured.Unstructured) string {
func extractPackageSourceCode(ctx context.Context, httpClient *http.Client, pkg *unstructured.Unstructured) string {
literalPaths := [][]string{
{"spec", "source", "literal"},
{"spec", "deployment", "literal"},
@@ -49,7 +49,7 @@ func extractPackageSourceCode(ctx context.Context, s *Server, pkg *unstructured.
if !found || strings.TrimSpace(urlValue) == "" {
continue
}
archiveBytes, err := fetchPackageArchive(ctx, s, urlValue)
archiveBytes, err := fetchPackageArchive(ctx, httpClient, urlValue)
if err != nil {
continue
}
@@ -62,12 +62,15 @@ func extractPackageSourceCode(ctx context.Context, s *Server, pkg *unstructured.
}
// fetchPackageArchive скачивает архив функции по URL из Fission storage.
func fetchPackageArchive(ctx context.Context, s *Server, archiveURL string) ([]byte, error) {
func fetchPackageArchive(ctx context.Context, httpClient *http.Client, archiveURL string) ([]byte, error) {
req, err := http.NewRequestWithContext(ctx, http.MethodGet, archiveURL, nil)
if err != nil {
return nil, err
}
resp, err := s.http.Do(req)
if httpClient == nil {
httpClient = http.DefaultClient
}
resp, err := httpClient.Do(req)
if err != nil {
return nil, err
}