refactor: Builder SoC + JWKS stub + unit tests
Builder SoC (builder/context.go):
- Moved generateDockerfile, runtimeBaseImage, zipToTarGz from handler/upload.go
to internal/builder/context.go.
Reason: knowledge about runtime images and build context structure is a
build concern, not an HTTP handler concern.
- Added PrepareContext(zipData []byte, runtime string) (*bytes.Buffer, error) —
single public entry point. Handler calls one function, gets ready buffer.
- zipToTarGz now accepts *zip.Reader instead of []byte to avoid double parsing.
- upload.go reduced from ~200 LOC to ~60 LOC (build logic gone).
auth.go — JWKS insertion point:
- Added verifySignature() stub with detailed comment explaining what v2
implementation needs (JWKS endpoint, kid lookup, RS256/ES256 verify).
- Shows exactly where to add the call in validateJWT.
Unit tests (9 total, all pass):
- controllers: TestBuildDeployment_EnvVarsSorted, TestBuildDeployment_EmptyEnv
- handler: TestHopByHopHeaders_* (3 tests)
- builder: TestPrepareContext_PythonWithRequirements, _NodeNoPackageJSON,
_UnsupportedRuntime, _DockerfileIsFirst
This commit is contained in:
@@ -222,7 +222,8 @@ func (r *FunctionReconciler) ensureDeployment(ctx context.Context, fn *slessv1al
|
||||
}
|
||||
return ctrl.Result{}, nil
|
||||
}
|
||||
// Изменено: 2026-03-11// buildDeployment формирует Deployment манифест для функции.
|
||||
|
||||
// Изменено: 2026-03-11// buildDeployment формирует Deployment манифест для функции.
|
||||
func (r *FunctionReconciler) buildDeployment(fn *slessv1alpha1.Function, namespace string) *appsv1.Deployment {
|
||||
replicas := int32(1)
|
||||
envVars := []corev1.EnvVar{
|
||||
|
||||
Reference in New Issue
Block a user