From 8fc9cb31c4e9c05d294a5031f1a022ae2d1913a8 Mon Sep 17 00:00:00 2001 From: Patrice Ferlet Date: Sun, 8 Mar 2026 23:50:29 +0100 Subject: [PATCH] feat(depends): Check call to kubernetes API --- internal/generator/deployment_test.go | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/internal/generator/deployment_test.go b/internal/generator/deployment_test.go index a83a471..42ce86c 100644 --- a/internal/generator/deployment_test.go +++ b/internal/generator/deployment_test.go @@ -152,6 +152,31 @@ services: if !strings.Contains(fullCommand, "wget") { t.Errorf("Expected wget command (K8s API method), got %s", fullCommand) } + + if !strings.Contains(fullCommand, "/api/v1/namespaces/") { + t.Errorf("Expected Kubernetes API call to /api/v1/namespaces/, got %s", fullCommand) + } + + if !strings.Contains(fullCommand, "/endpoints/") { + t.Errorf("Expected Kubernetes API call to /endpoints/, got %s", fullCommand) + } + + if len(initContainer.Env) == 0 { + t.Errorf("Expected environment variables to be set for namespace") + } + + hasNamespace := false + for _, env := range initContainer.Env { + if env.Name == "NAMESPACE" && env.ValueFrom != nil && env.ValueFrom.FieldRef != nil { + if env.ValueFrom.FieldRef.FieldPath == "metadata.namespace" { + hasNamespace = true + break + } + } + } + if !hasNamespace { + t.Errorf("Expected NAMESPACE env var with metadata.namespace fieldRef") + } } func TestDependsOnLegacy(t *testing.T) {