gurkankaymak / hocon

go implementation of lightbend's HOCON configuration library https://github.com/lightbend/config
MIT License
79 stars 17 forks source link

Use default value for optional env variables #13

Closed paluszkiewiczB closed 2 years ago

paluszkiewiczB commented 2 years ago

This change should fix issue https://github.com/gurkankaymak/hocon/issues/8

Introduces new String() syntax. For config: a: "value", a: "$?ENV} will be returned "(value | ${?ENV})"

If more than one alternative is provided: a: "value", a: "${REQUIRED}, a: ${?OPTIONAL} the first substitution will never be resolved - error won't be returned even if substitution is invalid.

Documentation does not mention how to handle such case, but maybe for config: a: "value", a: "${?PRESENT}, a:$?ABSENT} and env variable PRESENT being set and ABSENT not being set, value of PRESENT should be returned? Current implementation will return "value".

codecov[bot] commented 2 years ago

Codecov Report

Merging #13 (5817de5) into master (e20be6b) will increase coverage by 0.14%. The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #13      +/-   ##
==========================================
+ Coverage   96.39%   96.53%   +0.14%     
==========================================
  Files           3        3              
  Lines         693      722      +29     
==========================================
+ Hits          668      697      +29     
  Misses         20       20              
  Partials        5        5              
Impacted Files Coverage Δ
config.go 92.01% <100.00%> (+0.13%) :arrow_up:
parser.go 98.67% <100.00%> (+0.07%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update e20be6b...5817de5. Read the comment docs.