Skip to content

Commit

Permalink
[Issue 10058]:apply-config-from-env.py to commented default values (a…
Browse files Browse the repository at this point in the history
…pache#10060)

Add handling of commented name=value so that apply-config-from-env.py may un-comment the values if needed.

It is common practice to leave default values commented out in the configuration files. By not handling the commented case, the end customer may need to jump through hoops(such as adding un-commented values via script)  to make changes to these values in a production environment. This enhancement will ease the process by allowing the script to catalog the commented as well as un-commented values, and make replacements to both as needed, leading to a smoother customer experience when a support situation calls for adjusting the value to a commented variable. 

If a value is not supplied to  a commented variable, then the line remains commented out, and the default value should be assumed by the application. 

Any lines that do not contain a = or result in a parsing error should be ignored and the original line left in the configuration file.
  • Loading branch information
klwilson227 authored Apr 1, 2021
1 parent 9d08f64 commit 4b7facf
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions docker/pulsar/scripts/apply-config-from-env.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,14 @@
for line in open(conf_filename):
lines.append(line)
line = line.strip()
if not line or line.startswith('#'):
if not line:
continue

try:
k,v = line.split('=', 1)
keys[k] = len(lines) - 1
if k.startswith('#'):
k = k[1:]
keys[k.strip()] = len(lines) - 1
except:
print("[%s] skip Processing %s" % (conf_filename, line))

Expand Down

0 comments on commit 4b7facf

Please sign in to comment.