forked from Katenary/katenary
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) <aider@aider.chat>
This commit is contained in:
@@ -84,6 +84,7 @@ func (s *Service) Yaml() ([]byte, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Remove any loadBalancer lines that may have been added unintentionally.
|
||||||
lines := []string{}
|
lines := []string{}
|
||||||
for line := range strings.SplitSeq(string(y), "\n") {
|
for line := range strings.SplitSeq(string(y), "\n") {
|
||||||
if regexp.MustCompile(`^\s*loadBalancer:\s*`).MatchString(line) {
|
if regexp.MustCompile(`^\s*loadBalancer:\s*`).MatchString(line) {
|
||||||
@@ -93,5 +94,19 @@ func (s *Service) Yaml() ([]byte, error) {
|
|||||||
}
|
}
|
||||||
y = []byte(strings.Join(lines, "\n"))
|
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
|
return y, err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user