fix: imagePullSecrets, SLESS_ENTRYPOINT, registry secret propagation
- function_controller: добавить RegistrySecret + OperatorNamespace, копировать sless-registry-auth в sless-fn-<ns>, выставлять imagePullSecrets в Deployment, также обновлять imagePullSecrets при reconcile - functionjob_controller: fnEnvVars включает SLESS_ENTRYPOINT, runner читает его - server.js + server.py: читать SLESS_ENTRYPOINT вместо hardcoded handler.js/py - rbac.yaml: добавить права на secrets - operator.yaml: v0.1.8 - main.go: передать RegistrySecret + OperatorNamespace в FunctionReconciler
This commit is contained in:
+14
-12
@@ -1,29 +1,31 @@
|
||||
// Изменено: 2026-03-07
|
||||
// Изменено: 2026-03-08
|
||||
// HTTP-обёртка для serverless функций на Node.js 20.
|
||||
// Загружает handler.js из /app/function/ и вызывает handle(event) на каждый запрос.
|
||||
// Соглашение: handler.js должен экспортировать async функцию handle(event).
|
||||
//
|
||||
// Пример handler.js:
|
||||
// exports.handle = async (event) => {
|
||||
// return { message: `Hello, ${event.name || 'World'}!` };
|
||||
// };
|
||||
// Загружает модуль из SLESS_ENTRYPOINT или handler.js по умолчанию.
|
||||
// Формат SLESS_ENTRYPOINT: "module-name.functionName" (например: handler-http.handle)
|
||||
|
||||
'use strict';
|
||||
|
||||
const http = require('http');
|
||||
const path = require('path');
|
||||
|
||||
const HANDLER_PATH = '/app/function/handler.js';
|
||||
const PORT = 8080;
|
||||
|
||||
// Разбираем SLESS_ENTRYPOINT="module.func" → файл и имя функции.
|
||||
// Fallback: handler.js + handle — для обратной совместимости.
|
||||
const entrypoint = process.env.SLESS_ENTRYPOINT || 'handler.handle';
|
||||
const dotIdx = entrypoint.lastIndexOf('.');
|
||||
const moduleName = dotIdx >= 0 ? entrypoint.slice(0, dotIdx) : entrypoint;
|
||||
const funcName = dotIdx >= 0 ? entrypoint.slice(dotIdx + 1) : 'handle';
|
||||
const HANDLER_PATH = path.join('/app/function', moduleName);
|
||||
|
||||
// Загружаем модуль пользователя один раз при старте — не на каждый запрос
|
||||
let userHandle;
|
||||
try {
|
||||
const mod = require(HANDLER_PATH);
|
||||
if (typeof mod.handle !== 'function') {
|
||||
throw new Error('handler.js must export a handle(event) function');
|
||||
if (typeof mod[funcName] !== 'function') {
|
||||
throw new Error(`${moduleName} must export a ${funcName}(event) function`);
|
||||
}
|
||||
userHandle = mod.handle;
|
||||
userHandle = mod[funcName];
|
||||
} catch (err) {
|
||||
console.error('Failed to load handler:', err.message);
|
||||
process.exit(1);
|
||||
|
||||
Reference in New Issue
Block a user