refactor: replace yq post-processing with dedicated no-gateway template#1248
Closed
bonzofenix wants to merge 3 commits into
Closed
refactor: replace yq post-processing with dedicated no-gateway template#1248bonzofenix wants to merge 3 commits into
bonzofenix wants to merge 3 commits into
Conversation
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.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



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=falsepath inbuild-extension-file.shhandled this by generating the extension file from the gateway-enabled template, then applying four sequentialyq --inplacemutations 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 plainif/elsebeforeenvsubst— no post-generation patching needed.All four
yq --inplacecalls removed — the no-gateway path no longer requires any YAML surgery at runtime.Test plan
shellcheckpasses onbuild-extension-file.shUSE_METRICSGATEWAY=false: verify metricsforwarder has syslog-client binding, metricsgateway has 0 instances, metricsgateway-config resource absent, metrics_gateway key absentUSE_METRICSGATEWAY=true: verify extension file is identical to before (gateway-enabled template path unchanged)🤖 Generated with Claude Code