scope namespace placeholder to installer_updater.yaml#385
Conversation
| @sed \ | ||
| -e "s|^ name: $(DEVZERO_MONITORING_NAMESPACE)$$| name: '{{.zxporter_namespace}}'|g" \ | ||
| -e "s|^ namespace: $(DEVZERO_MONITORING_NAMESPACE)$$| namespace: '{{.zxporter_namespace}}'|g" \ | ||
| -e "s|^ namespace: $(DEVZERO_MONITORING_NAMESPACE)$$| namespace: '{{.zxporter_namespace}}'|g" \ | ||
| $(DIST_DIR)/installer_updater.yaml > $(DIST_DIR)/installer_updater.yaml.tmp && mv $(DIST_DIR)/installer_updater.yaml.tmp $(DIST_DIR)/installer_updater.yaml |
There was a problem hiding this comment.
💡 Edge Case: sed patterns break if DEVZERO_MONITORING_NAMESPACE is empty
If DEVZERO_MONITORING_NAMESPACE is explicitly set to an empty string (e.g., make DEVZERO_MONITORING_NAMESPACE=), the sed patterns degenerate to matching lines like ^ name: $, which would not match intended lines but could silently skip all replacements, producing an installer_updater.yaml without namespace placeholders. Consider adding a guard check.
Add a guard to fail early if DEVZERO_MONITORING_NAMESPACE is empty:
installer-without-configmap:
@cp $(DIST_BACKEND_INSTALL_BUNDLE) $(DIST_DIR)/installer_updater.yaml
@$(YQ) -i 'select((.kind != "ConfigMap" or .metadata.name != "devzero-zxporter-env-config") and (.kind != "Secret" or .metadata.name != "devzero-zxporter-token"))' $(DIST_DIR)/installer_updater.yaml
@if [ -z "$(DEVZERO_MONITORING_NAMESPACE)" ]; then echo "ERROR: DEVZERO_MONITORING_NAMESPACE must be set" >&2; exit 1; fi
@sed \
-e "s|^ name: $(DEVZERO_MONITORING_NAMESPACE)$$| name: '{{.zxporter_namespace}}'|g" \
-e "s|^ namespace: $(DEVZERO_MONITORING_NAMESPACE)$$| namespace: '{{.zxporter_namespace}}'|g" \
-e "s|^ namespace: $(DEVZERO_MONITORING_NAMESPACE)$$| namespace: '{{.zxporter_namespace}}'|g" \
$(DIST_DIR)/installer_updater.yaml > $(DIST_DIR)/installer_updater.yaml.tmp && mv $(DIST_DIR)/installer_updater.yaml.tmp $(DIST_DIR)/installer_updater.yaml
Was this helpful? React with 👍 / 👎
Code Review 👍 Approved with suggestions 0 resolved / 1 findingsScopes the 💡 Edge Case: sed patterns break if DEVZERO_MONITORING_NAMESPACE is emptyIf Add a guard to fail early if DEVZERO_MONITORING_NAMESPACE is empty🤖 Prompt for agentsWas this helpful? React with 👍 / 👎 | Gitar |
scope the
{{.zxporter_namespace}}templating todist/installer_updater.yamlonly.📚 Description of Changes
Provide an overview of your changes and why they’re needed. Link to any related issues (e.g., "Fixes #123"). If your PR fixes a bug, resolves a feature request, or updates documentation, please explain how.
What Changed:
(Describe the modifications, additions, or removals.)
Why This Change:
(Explain the problem this PR addresses or the improvement it provides.)
Affected Components:
(Which component does this change affect? - put x for all components)
Compose
K8s
Other (please specify)
❓ Motivation and Context
Why is this change required? What problem does it solve?
Context:
(Provide background information or link to related discussions/issues.)
Relevant Tasks/Issues:
(e.g., Fixes: #GitHub Issue)
🔍 Types of Changes
Indicate which type of changes your code introduces (check all that apply):
🔬 QA / Verification Steps
Describe the steps a reviewer should take to verify your changes:
make testto verify all tests pass.")make create-kind && make deploy.")✅ Global Checklist
Please check all boxes that apply: