You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by pe...@apache.org on 2021/04/01 09:56:00 UTC

[pulsar] 01/02: [Issue 10058]:apply-config-from-env.py to commented default values (#10060)

This is an automated email from the ASF dual-hosted git repository.

penghui pushed a commit to branch branch-2.7
in repository https://gitbox.apache.org/repos/asf/pulsar.git

commit cf76da37226308bc3e3f627fdeae161d72076ee4
Author: Kevin Wilson <kl...@comcast.net>
AuthorDate: Wed Mar 31 21:49:38 2021 -0600

    [Issue 10058]:apply-config-from-env.py to commented default values (#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 [...]
    
    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.
    
    (cherry picked from commit 4b7facf49b1ef166f21ccd1b3aea37d482900313)
---
 docker/pulsar/scripts/apply-config-from-env.py | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/docker/pulsar/scripts/apply-config-from-env.py b/docker/pulsar/scripts/apply-config-from-env.py
index 992b8f7..803c4f1 100755
--- a/docker/pulsar/scripts/apply-config-from-env.py
+++ b/docker/pulsar/scripts/apply-config-from-env.py
@@ -44,12 +44,14 @@ for conf_filename in conf_files:
     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))