Skip to content

[nr-k8s-otel-collector] Update ConfigMap formatting for kubectl edit#2194

Draft
bpschmitt wants to merge 1 commit intonewrelic:masterfrom
bpschmitt:fix-configmap-indent
Draft

[nr-k8s-otel-collector] Update ConfigMap formatting for kubectl edit#2194
bpschmitt wants to merge 1 commit intonewrelic:masterfrom
bpschmitt:fix-configmap-indent

Conversation

@bpschmitt
Copy link
Copy Markdown
Contributor

What this PR does / why we need it:

ConfigMap Indentation Fix - Summary

Problem

Configmaps were displaying escaped newline characters (\n) when viewed with kubectl edit, making them unreadable.

Root Cause

  • nindent adds newlines + indentation and is designed for injecting YAML into YAML structures
  • Inside a literal block (|), nindent was escaping newlines instead of treating them as literal text
  • Additionally, template definitions had unnecessary leading indentation and blank lines that contributed to extra whitespace

Changes Made

1. charts/nr-k8s-otel-collector/templates/_config_map.tpl

  • Removed blank lines after all define statements (they were output as extra whitespace)
  • Removed unnecessary leading indentation from template logic (all if/end statements now at column 0)
  • Added | indent N filter to all toYaml calls to handle indentation within the template:
    • indent 6 for receivers, processors, exporters, connectors
    • indent 8 for pipelines
  • This ensures proper indentation is applied BEFORE the output is inserted into the literal block

2. charts/nr-k8s-otel-collector/templates/deployment-configmap.yaml

  • Removed all | nindent N filters from include calls inside the literal block
  • Affected lines: 11, 14, 182-183, 741-742, 749, 791, 797, 824, 835, 839, 908, 912, 920, 923, 938, 942
  • The indentation is now handled in the template definitions themselves

3. charts/nr-k8s-otel-collector/templates/daemonset-configmap.yaml

  • Removed all | nindent N filters from include calls inside the literal block
  • Same lines affected as deployment template
  • The indentation is now handled in the template definitions themselves

Result

  • ✅ Configmaps now render with proper YAML formatting in kubectl edit
  • ✅ No escaped \n characters in the output
  • ✅ Custom processors, exporters, connectors, and pipelines are properly indented when included

Which issue this PR fixes

(optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close that issue when PR gets merged)

  • fixes #

Special notes for your reviewer:

Checklist

[Place an '[x]' (no spaces) in all applicable fields. Please remove unrelated fields.]

  • Chart Version bumped
  • Title of the PR starts with chart name (e.g. [mychartname])

Release Notes to Publish (nr-k8s-otel-collector)

If this PR contains changes in nr-k8s-otel-collector, please complete the following section. All other charts should ignore this section.

🚀 What's Changed

  • Tell the world about the latest changes in the chart.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant