Skip to content

refactor: replace yq post-processing with dedicated no-gateway template#1248

Closed
bonzofenix wants to merge 3 commits into
mainfrom
worktree-fix-build-extension-file
Closed

refactor: replace yq post-processing with dedicated no-gateway template#1248
bonzofenix wants to merge 3 commits into
mainfrom
worktree-fix-build-extension-file

Conversation

@bonzofenix

@bonzofenix bonzofenix commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

What and why

The metricsgateway is an optional component — some deployments route custom metrics directly from metricsforwarder to syslog (no gateway), while others route through metricsgateway first. The USE_METRICSGATEWAY=false path in build-extension-file.sh handled this by generating the extension file from the gateway-enabled template, then applying four sequential yq --inplace mutations to remove the gateway wiring. The final file state was only visible by mentally applying all four patches — you couldn't just open a file and see what a no-gateway deployment looks like.

Changes

Dedicated no-gateway template — added extension-file-no-gateway.tpl.yaml, a standalone template for deployments where metricsgateway is disabled. It has metricsforwarder binding syslog-client directly (instead of via metricsgateway), metricsgateway set to 0 instances, and the metricsgateway-config resource and metrics_gateway key removed. The script now picks the right template with a plain if/else before envsubst — no post-generation patching needed.

All four yq --inplace calls removed — the no-gateway path no longer requires any YAML surgery at runtime.

Test plan

  • shellcheck passes on build-extension-file.sh
  • Deploy with USE_METRICSGATEWAY=false: verify metricsforwarder has syslog-client binding, metricsgateway has 0 instances, metricsgateway-config resource absent, metrics_gateway key absent
  • Deploy with USE_METRICSGATEWAY=true: verify extension file is identical to before (gateway-enabled template path unchanged)

🤖 Generated with Claude Code

Single chained yq expression with multiple `|` operations was hard to
follow. Split into four focused invocations, each with a comment
explaining which patch it applies.
Instead of generating from the gateway template then patching with four
yq mutations, select the appropriate template upfront based on
USE_METRICSGATEWAY. The no-gateway template has metricsforwarder
binding syslog-client directly, metricsgateway at 0 instances, and
no metricsgateway-config resource or metrics_gateway key.
@bonzofenix bonzofenix changed the title refactor: split compound yq expression into separate invocations refactor: replace yq post-processing with dedicated no-gateway template Jun 9, 2026
@bonzofenix bonzofenix self-assigned this Jun 9, 2026
@bonzofenix bonzofenix closed this Jun 25, 2026
@sonarqubecloud

Copy link
Copy Markdown

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant