mirror of https://github.com/zulip/zulip.git
zulip_tools: Add a get_config_bool to match Puppet logic.
Unfortunately, the existing use of this logic in `process_fts_updates` cannot switch to using this code, as that code cannot import zulip_tools.
This commit is contained in:
parent
4d02ac6fb1
commit
530980cf31
|
@ -6,7 +6,8 @@ module Puppet::Parser::Functions
|
|||
output = `/usr/bin/crudini --get #{zulip_conf_path} #{joined} 2>&1`; result = $?.success?
|
||||
if result
|
||||
if [true, false].include? default
|
||||
# If the default is a bool, coerce into a bool
|
||||
# If the default is a bool, coerce into a bool. This list is also
|
||||
# maintained in scripts/lib/zulip_tools.py
|
||||
['1','y','t','true','yes','enable','enabled'].include? output.strip.downcase
|
||||
else
|
||||
output.strip
|
||||
|
|
|
@ -595,6 +595,16 @@ def get_config(
|
|||
return default_value
|
||||
|
||||
|
||||
def get_config_bool(
|
||||
config_file: configparser.RawConfigParser, section: str, key: str, default_value: bool = False
|
||||
) -> bool:
|
||||
if config_file.has_option(section, key):
|
||||
val = config_file.get(section, key)
|
||||
# This list is parallel to puppet/zulip/lib/puppet/parser/functions/zulipconf.rb
|
||||
return val in ["1", "y", "t", "true", "yes", "enable", "enabled"]
|
||||
return default_value
|
||||
|
||||
|
||||
def get_config_file() -> configparser.RawConfigParser:
|
||||
config_file = configparser.RawConfigParser()
|
||||
config_file.read("/etc/zulip/zulip.conf")
|
||||
|
|
Loading…
Reference in New Issue