Skip to content

Commit dfe3483

Browse files
authored
Merge pull request voxpupuli#715 from tylerjl/yml-unquoted-numerics
Enforce proper numeric datatypes in config hash
2 parents 9eebc6c + 94077f3 commit dfe3483

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
#### Changes
1616
* The `api_ca_file` and `api_ca_path` parameters have been added to support custom CA bundles for API access.
17+
* Numerics in elasticsearch.yml will always be properly unquoted.
1718

1819
#### Testing changes
1920

spec/templates/001_elasticsearch.yml.erb_spec.rb

+12
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,16 @@ def unindent
7474
}.config))
7575
end
7676

77+
it 'should not quote numeric values' do
78+
harness.set(
79+
'@data', {
80+
'some.setting' => '10'
81+
}
82+
)
83+
84+
expect( YAML.load(harness.run) ).to eq( YAML.load(%q{
85+
some.setting: 10
86+
}.config))
87+
end
88+
7789
end

templates/etc/elasticsearch/elasticsearch.yml.erb

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
### MANAGED BY PUPPET ###
22
<%-
33
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__),"..","..","..","lib"))
4+
require 'puppet_x/elastic/deep_to_i'
45
require 'puppet_x/elastic/hash'
56

67
@yml_string = ''
78

89
910

1011
# Sort Hash and transform it into yaml
11-
@yml_string += @data.extend(Puppet_X::Elastic::SortedHash).to_yaml
12+
@yml_string += Puppet_X::Elastic::deep_to_i(
13+
@data
14+
).extend(
15+
Puppet_X::Elastic::SortedHash
16+
).to_yaml
1217

1318
# Puppet < 4 uses ZAML, which has some deviations from Puppet 4 YAML
1419
# implementation

0 commit comments

Comments
 (0)