Repository navigation
✨ Add support for references to secrets or configmaps in env variables import - #350
Conversation
… refs Signed-off-by: Paolo Dettori <[email protected]>
Signed-off-by: Paolo Dettori <[email protected]>
Signed-off-by: Paolo Dettori <[email protected]>
There was a problem hiding this comment.
Pull Request Overview
This PR adds support for importing environment variables from .env files that reference Kubernetes Secrets or ConfigMaps instead of containing plaintext values. The implementation allows JSON-encoded references (e.g., {"secretKeyRef": {...}}) in .env files to be parsed and included as valueFrom entries in generated manifests.
Key changes:
- New
parse_env_file()function that handles JSON-encoded secret/configmap references alongside plain string values - UI enhancements to support "Structured" vs "Plain" mode for environment variables with JSON validation
- Comprehensive test coverage for the new parsing logic and integration with resource body construction
Reviewed Changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| kagenti/ui/lib/build_utils.py | Implements JSON-aware env parsing, refactors inline parser to module-level function, adds UI controls for structured/plain env modes, and updates validation logic to handle both value types |
| kagenti/ui/tests/test_env_parser.py | Unit tests covering plain values, valueFrom JSON, shorthand secretKeyRef, and invalid JSON fallback behavior |
| kagenti/ui/tests/test_integration_resource_body.py | Integration test verifying structured env entries flow correctly into Kubernetes resource body |
| docs/new-agent.md | Documents the new feature with usage examples, migration notes, and quick-start guide for creating referenced Secrets |
| .github/workflows/ci.yaml | Enables pytest execution in CI pipeline |
Comments suppressed due to low confidence (1)
kagenti/ui/lib/build_utils.py:1
- Syntax error:
env_var[\"name\".strip()...]attempts to use a string literal as a dictionary key. This should beenv_var[\"name\"].strip()to access the 'name' key and strip it.
# Assisted by watsonx Code Assistant
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: Paolo Dettori <[email protected]>
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 5 out of 6 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: Paolo Dettori <[email protected]>
Summary
This PR adds support for importing environment variables from .env files that reference Kubernetes Secrets or ConfigMaps instead of containing plaintext values. The implementation allows JSON-encoded references (e.g., {"secretKeyRef": {...}}) in .env files to be parsed and included as valueFrom entries in generated manifests.
Key changes:
Related issue(s)
Fixes #336