Skip to content

[cmd/mdatagen] Enforce tab indentation in Go template files#15444

Open
Goutham-Annem wants to merge 3 commits into
open-telemetry:mainfrom
Goutham-Annem:fix/14698-check-template-tabs
Open

[cmd/mdatagen] Enforce tab indentation in Go template files#15444
Goutham-Annem wants to merge 3 commits into
open-telemetry:mainfrom
Goutham-Annem:fix/14698-check-template-tabs

Conversation

@Goutham-Annem

@Goutham-Annem Goutham-Annem commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Description

Added a check-template-tabs Makefile target and a corresponding CI step in build-and-test.yml that fails if any .go.tmpl file under cmd/mdatagen or cmd/builder contains lines with leading spaces. Converted the two remaining offending templates (config_from_cfggen.go.tmpl and config_from_cfggen_test.go.tmpl) from space indentation to tab indentation to bring them in line with all other templates.

Link to tracking issue

Fixes #14698

Testing

Ran make check-template-tabs locally — passes with no output. All other .go.tmpl files were already tab-indented and continue to pass.

Documentation

No documentation changes needed. The check-template-tabs target is self-documenting via the Makefile.

Authorship

  • I, a human, wrote this pull request description myself.

@Goutham-Annem
Goutham-Annem requested review from a team and dmitryax as code owners June 16, 2026 01:32
@github-actions github-actions Bot added release:risky-change This change may affect the release cmd/mdatagen labels Jun 16, 2026
@Goutham-Annem
Goutham-Annem force-pushed the fix/14698-check-template-tabs branch 2 times, most recently from 2f2cd7c to db5b9f8 Compare June 24, 2026 19:45
@codspeed-hq

codspeed-hq Bot commented Jun 24, 2026

Copy link
Copy Markdown

Merging this PR will create unknown performance changes

⚠️ Unknown Walltime execution environment detected

Using the Walltime instrument on standard Hosted Runners will lead to inconsistent data.

For the most accurate results, we recommend using CodSpeed Macro Runners: bare-metal machines fine-tuned for performance measurement consistency.

⏩ 4 skipped benchmarks1
🗄️ 2 archived benchmarks run2


Comparing Goutham-Annem:fix/14698-check-template-tabs (a702d72) with main (fe96e04)

Open in CodSpeed

Footnotes

  1. 4 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

  2. 2 benchmarks were run, but are now archived. If they were deleted in another branch, consider rebasing to remove them from the report. Instead if they were added back, click here to restore them.

@codecov

codecov Bot commented Jun 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.03%. Comparing base (52e6bf4) to head (bc52693).

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #15444   +/-   ##
=======================================
  Coverage   91.03%   91.03%           
=======================================
  Files         729      729           
  Lines       48491    48491           
=======================================
  Hits        44144    44144           
  Misses       3020     3020           
  Partials     1327     1327           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Goutham-Annem
Goutham-Annem force-pushed the fix/14698-check-template-tabs branch 3 times, most recently from 14820e0 to a167a91 Compare July 4, 2026 08:37
@Goutham-Annem
Goutham-Annem force-pushed the fix/14698-check-template-tabs branch from a167a91 to a702d72 Compare July 10, 2026 10:44
@Goutham-Annem
Goutham-Annem force-pushed the fix/14698-check-template-tabs branch from a702d72 to e182186 Compare July 18, 2026 06:49
Go template files in cmd/mdatagen/internal/templates/ were using
4-space indentation in code blocks generated by upstream additions.
Convert all leading 4-space groups to tabs to match Go formatting
conventions and make the templates consistent with gofmt output.

Assisted-by: Claude Sonnet 4.6
@Goutham-Annem
Goutham-Annem force-pushed the fix/14698-check-template-tabs branch from e182186 to 296b80d Compare July 24, 2026 05:51
config.schema.yaml.tmpl generates YAML output; YAML forbids tab
characters as indentation (yaml spec §5.5). Reverting to spaces
prevents 'found character that cannot start any token' from mdatagen
during make gogenerate.

Also add required .chloggen entry for this PR.

Assisted-by: Claude Sonnet 4.6
documentation.md.tmpl contains YAML code examples (enabled: true/false
inside metric/event config snippets) that are emitted verbatim into the
generated documentation.md files. Tab indentation in those snippets
caused make gogenerate to produce tabs in the output, failing the
'Generated code is out of date' diff check.

Only Go template files (.go.tmpl) should use tab indentation.

Assisted-by: Claude Sonnet 4.6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cmd/mdatagen release:risky-change This change may affect the release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ensure templates are properly tab-formatted

1 participant