feat: option to change POSIX variable name regex - facilitate passthrough#573
Open
space88man wants to merge 1 commit intotheskumar:mainfrom
Open
feat: option to change POSIX variable name regex - facilitate passthrough#573space88man wants to merge 1 commit intotheskumar:mainfrom
space88man wants to merge 1 commit intotheskumar:mainfrom
Conversation
801b75c to
269d2dc
Compare
269d2dc to
c34e1a1
Compare
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.
Background
There are certain situations where a string
${xxxxxxxx}should not be a candidate for variable substitution. This is very common in Spring Boot applications where${a.b.c.d}is property placeholder syntaxThis PR allows the user to narrow the scope of
dotenv.variables._posix_variableso that some strings that resemble POSIX variable substitution can be treated literally.Before this PR:
After this PR:
Real-world use case: 12-factor'ing Spring Boot applications where some properties refer to other properties
${a.b.c.d}in their valuesFeature Implementation
dotenv.set_variable_name_pattern(....)to set the regex for the naming convention. This is a substring that will be used inside the${xxxxxx:-yyyyyy}matcher. IOW, this pattern is only used to match the variable name, not the enclosing${...}dotenv.set_variable_name_pattern()This feature does not affect any existing code as it is purely opt-in
Thread Safety
dotenv.variablesso is not thread safeDeferred Ideas
_posix_variable- this would be very intrusive so not in the scope of this feature_posix_variable- this is a low risk thread-safety enhancement where each thread can set its own_posix_variableUsage
Benefits
Workaround
Current workaround