|
4 | 4 | require 'puppet/file_serving/metadata' |
5 | 5 |
|
6 | 6 | require 'puppet_x/elastic/deep_implode' |
| 7 | +require 'puppet_x/elastic/deep_to_i' |
7 | 8 | require 'puppet_x/elastic/deep_to_s' |
8 | 9 | require 'puppet_x/elastic/elasticsearch_rest_resource' |
9 | 10 |
|
|
32 | 33 | # `in` and `should` states consistent if the user hasn't |
33 | 34 | # provided any. |
34 | 35 | # |
35 | | - # We use deep_to_s to normalize hash values to strings, whether from |
36 | | - # user-defined resources or when reading from the API. |
| 36 | + # The value is first stringified, then integers are parse out as |
| 37 | + # necessary, since the Elasticsearch API enforces some fields to be |
| 38 | + # integers. |
37 | 39 | # |
38 | 40 | # We also need to fully qualify index settings, since users |
39 | 41 | # can define those with the index json key absent, but the API |
40 | 42 | # always fully qualifies them. |
41 | | - { 'order' => '0', 'aliases' => {}, 'mappings' => {} }.merge( |
42 | | - Puppet_X::Elastic.deep_to_s( |
43 | | - value.tap do |val| |
44 | | - if val.key? 'settings' |
45 | | - val['settings']['index'] = {} unless val['settings'].key? 'index' |
46 | | - (val['settings'].keys - ['index']).each do |setting| |
47 | | - new_key = if setting.start_with? 'index.' |
48 | | - setting[6..-1] |
49 | | - else |
50 | | - setting |
51 | | - end |
52 | | - val['settings']['index'][new_key] = \ |
53 | | - val['settings'].delete setting |
| 43 | + { 'order' => 0, 'aliases' => {}, 'mappings' => {} }.merge( |
| 44 | + Puppet_X::Elastic.deep_to_i( |
| 45 | + Puppet_X::Elastic.deep_to_s( |
| 46 | + value.tap do |val| |
| 47 | + if val.key? 'settings' |
| 48 | + val['settings']['index'] = {} unless val['settings'].key? 'index' |
| 49 | + (val['settings'].keys - ['index']).each do |setting| |
| 50 | + new_key = if setting.start_with? 'index.' |
| 51 | + setting[6..-1] |
| 52 | + else |
| 53 | + setting |
| 54 | + end |
| 55 | + val['settings']['index'][new_key] = \ |
| 56 | + val['settings'].delete setting |
| 57 | + end |
54 | 58 | end |
55 | 59 | end |
56 | | - end |
| 60 | + ) |
57 | 61 | ) |
58 | 62 | ) |
59 | 63 | end |
|
0 commit comments