Skip to content

scope namespace placeholder to installer_updater.yaml#385

Open
sandipanpanda wants to merge 1 commit into
mainfrom
zxp-secret-placeholder
Open

scope namespace placeholder to installer_updater.yaml#385
sandipanpanda wants to merge 1 commit into
mainfrom
zxp-secret-placeholder

Conversation

@sandipanpanda
Copy link
Copy Markdown
Contributor

scope the {{.zxporter_namespace}} templating to dist/installer_updater.yaml only.

📚 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):

  • BUGFIX: Non-breaking fix for an issue.
  • NEW FEATURE: Non-breaking addition of functionality.
  • BREAKING CHANGE: Fix or feature that causes existing functionality to not work as expected.
  • ENHANCEMENT: Improvement to existing functionality.
  • CHORE: Changes that do not affect production (e.g., documentation, build tooling, CI).

🔬 QA / Verification Steps

Describe the steps a reviewer should take to verify your changes:

  1. (Step one: e.g., "Run make test to verify all tests pass.")
  2. (Step two: e.g., "Deploy to a Kind cluster with make create-kind && make deploy.")
  3. (Additional steps as needed.)

✅ Global Checklist

Please check all boxes that apply:

  • I have read and followed the CONTRIBUTING guidelines.
  • My code follows the code style of this project.
  • I have updated the documentation as needed.
  • I have added tests that cover my changes.
  • All new and existing tests have passed locally.
  • I have run this code in a local environment to verify functionality.
  • I have considered the security implications of this change.

Comment thread Makefile
Comment on lines +335 to +339
@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
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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 👍 / 👎

@gitar-bot
Copy link
Copy Markdown

gitar-bot Bot commented May 25, 2026

Code Review 👍 Approved with suggestions 0 resolved / 1 findings

Scopes the {{.zxporter_namespace}} templating exclusively to installer_updater.yaml. Note that the current sed patterns may break if DEVZERO_MONITORING_NAMESPACE is set to an empty string.

💡 Edge Case: sed patterns break if DEVZERO_MONITORING_NAMESPACE is empty

📄 Makefile:335-339

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
🤖 Prompt for agents
Code Review: Scopes the `{{.zxporter_namespace}}` templating exclusively to `installer_updater.yaml`. Note that the current sed patterns may break if `DEVZERO_MONITORING_NAMESPACE` is set to an empty string.

1. 💡 Edge Case: sed patterns break if DEVZERO_MONITORING_NAMESPACE is empty
   Files: Makefile:335-339

   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.

   Fix (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 👍 / 👎 | Gitar

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