puppetlabs-inifile icon indicating copy to clipboard operation
puppetlabs-inifile copied to clipboard

Puppet::Util::Inifile: set_value does not honor the default key_val_separator

Open kajinamit opened this issue 5 months ago • 0 comments

Describe the Bug

In Puppet OpenStack project we use the Puppet::Util::IniFile utility class to manipulate ini settings. We recently discovered that its set_value method uses nil (which is translated to '') as the default separator unless separator is explicitly passed. This is inconsistent with the other logic (eg loading options from config file) and is confusing.

Expected Behavior

The set_value method honors the key_value_separator unless separator is explicitly defined

Steps to Reproduce

Steps to reproduce the behavior:

  1. Run the following code snippet
config = Puppet::Util::IniFile.new('./test.conf')
config.set_value('foo', 'bar', 'baz')

Current implementation results in dumping

[foo]
barbaz

into the test.conf file.

Environment

  • Version: 6.1.1
  • Platform: CentOS Stream 9

Additional Context

N/A

kajinamit avatar Sep 20 '24 12:09 kajinamit