Commit 0cca7b8
Add support for one zero and yes no boolean strings in environement variables provider (#120)
### Motivation
Add support for 1, 0, and YES, NO boolean strings in
EnvironmentVariablesProvider. Support for YES and NO boolean strings was
not discussed in the original issue. From personal experience, I found
it interesting to include it. If rejected, I will remove it. I tried to
remain consitent with the existing decoders and the way they are used by
the provider.
Closes #110
### Modifications
The EnvironmentVariablesProvider's bool decoder is configurable and can
be initialized with support for true/false, 1/0, yes/no, or any
combination of them.
### Result
Usage of EnvironmentVariablesProvider has not changed, but by default
all pairs of boolean strings are accepted when retrieving values as Bool
or BoolArray. Client code can configure the provider to use a bool
decoder with support only for true/false strings.
If it is more important to keep the behavior as it was, meaning default
support for true/false only in the provider, then I will modify the
default set for the EnvironmentVariablesProvider BoolDecoder.
### Test Plan
The decoder is tested with dedicated tests, and additional tests for
receiving a value from a provider were added to test the integration of
BoolDecoder with EnvironmentVariablesProvider.
Code is commented, and tests are green locally.
---------
Co-authored-by: Honza Dvorsky <honza@apple.com>1 parent 08206f5 commit 0cca7b8
File tree
2 files changed
+70
-2
lines changed- Sources/Configuration/Providers/EnvironmentVariables
- Tests/ConfigurationTests
2 files changed
+70
-2
lines changedLines changed: 12 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
142 | 142 | | |
143 | 143 | | |
144 | 144 | | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
145 | 155 | | |
146 | 156 | | |
147 | 157 | | |
| |||
393 | 403 | | |
394 | 404 | | |
395 | 405 | | |
396 | | - | |
| 406 | + | |
397 | 407 | | |
398 | 408 | | |
399 | 409 | | |
| |||
426 | 436 | | |
427 | 437 | | |
428 | 438 | | |
429 | | - | |
| 439 | + | |
430 | 440 | | |
431 | 441 | | |
432 | 442 | | |
| |||
Lines changed: 58 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
71 | 129 | | |
72 | 130 | | |
73 | 131 | | |
| |||
0 commit comments