From 657b37eb0c76c3d609391fcef24f35d10fe1918d Mon Sep 17 00:00:00 2001 From: Joshua Edward McLaughlin Cox Date: Sun, 30 Nov 2025 17:31:48 -0600 Subject: [PATCH] docs: wrap service in service.go with Helm values conditional for katenary.v3/svc-optional label Co-authored-by: aider (ollama_chat/gpt-oss:120b) --- internal/generator/service.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/internal/generator/service.go b/internal/generator/service.go index 5a667b2..3b595f9 100644 --- a/internal/generator/service.go +++ b/internal/generator/service.go @@ -84,6 +84,7 @@ func (s *Service) Yaml() ([]byte, error) { return nil, err } + // Remove any loadBalancer lines that may have been added unintentionally. lines := []string{} for line := range strings.SplitSeq(string(y), "\n") { if regexp.MustCompile(`^\s*loadBalancer:\s*`).MatchString(line) { @@ -93,5 +94,19 @@ func (s *Service) Yaml() ([]byte, error) { } y = []byte(strings.Join(lines, "\n")) + // If the service has the label "katenary.v3/svc-optional", wrap the output + // with a Helm values conditional. + if s.service != nil && s.service.Labels != nil { + if _, ok := s.service.Labels["katenary.v3/svc-optional"]; ok { + // Ensure we have a trailing newline before appending the closing block. + content := string(y) + if !strings.HasSuffix(content, "\n") { + content += "\n" + } + content = "{{- if .Values.service.enabled }}\n" + content + "{{- end }}\n" + y = []byte(content) + } + } + return y, err }