feat(config): add support for environment variable placeholders in config #1090
Closed
feat(config): add support for environment variable placeholders in config #1090
Conversation
Contributor
There was a problem hiding this comment.
1 issue found across 3 files
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="apps/generator-cli/src/app/services/config.service.ts">
<violation number="1" location="apps/generator-cli/src/app/services/config.service.ts:145">
P1: Calling `replacePlaceholders()` in `read()` will corrupt the config file when `set()` is used. The `set()` method calls `read()` to get the current config, modifies it, and writes it back. Since placeholders are now replaced during `read()`, the original `${VAR}` syntax will be permanently overwritten with resolved values. Consider applying placeholder replacement only in `get()` when returning values, not in `read()` which is also used for config modification.</violation>
</file>
Reply to cubic to teach it or ask questions. Tag @cubic-dev-ai to re-run a review.
| fs.readJSONSync(this.configFile, { throws: false, encoding: 'utf8' }), | ||
| ); | ||
|
|
||
| return this.replacePlaceholders(config); |
Contributor
There was a problem hiding this comment.
P1: Calling replacePlaceholders() in read() will corrupt the config file when set() is used. The set() method calls read() to get the current config, modifies it, and writes it back. Since placeholders are now replaced during read(), the original ${VAR} syntax will be permanently overwritten with resolved values. Consider applying placeholder replacement only in get() when returning values, not in read() which is also used for config modification.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/generator-cli/src/app/services/config.service.ts, line 145:
<comment>Calling `replacePlaceholders()` in `read()` will corrupt the config file when `set()` is used. The `set()` method calls `read()` to get the current config, modifies it, and writes it back. Since placeholders are now replaced during `read()`, the original `${VAR}` syntax will be permanently overwritten with resolved values. Consider applying placeholder replacement only in `get()` when returning values, not in `read()` which is also used for config modification.</comment>
<file context>
@@ -137,10 +137,57 @@ export class ConfigService {
fs.readJSONSync(this.configFile, { throws: false, encoding: 'utf8' }),
);
+
+ return this.replacePlaceholders(config);
+ }
+
</file context>
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.
Summary by cubic
Add environment variable placeholder support in openapitools.json so configs can reference ${VAR} or ${env.VAR} for dynamic values. Updated docs and tests to cover usage.
Written for commit 5325b17. Summary will update automatically on new commits.
based on #1031