hiera-mysql-json-backend 2.0.0 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 7089e8b0947896353a2650c6e40859181b27daef
4
- data.tar.gz: 15a1065f32602bc4f9b40655744e5b67a26a4e77
2
+ SHA256:
3
+ metadata.gz: 8a1886efe7ccceb511cc7e6e478badcf22bc7e99ae84cf146953cc4c4a8578fa
4
+ data.tar.gz: e684e16256fae20776ed08e0d0b4ba5bd44be8c29a305bd193a05031c66798f0
5
5
  SHA512:
6
- metadata.gz: 8ef7562939428dc62bd2696d331593c7f2098420920ecd1cd0cfad919c2a87f325bb548fb9a8a18056f61fe9b40c97ca94196fcbf2e53d9c2cb0ababf1fc95a1
7
- data.tar.gz: 8ac1c9fef7bfd2c670ec9a2cf679a0b516d11c76553bde7592150b965be005424d592bc8098e1eb7b5d2c855501b8f7476d16834359d4a0d28d9ae34494d18e4
6
+ metadata.gz: 49f9b84e47ad2fcea9303835988658600311674940adc79e1babb1027900771b939a035222c984d8911db34f246dde10d39b00b07b28074ad112a9234c29b168
7
+ data.tar.gz: ca802b9dea41bf44a7319200b2aef8c63bd6215b445b7b90096093f2ab84e4cb3ed6aa5a890fb8d6833ce7c353f7ed06bcab0a59cda05a08702138243d3c6e43
data/CHANGELOG.md CHANGED
@@ -20,3 +20,11 @@
20
20
 
21
21
  - If we cannot parse JSON as json, do something nasty to try if the value is a
22
22
  boolean
23
+
24
+ ### 2.1.0
25
+
26
+ - Host/domain constraints can now be defined per hierarchy file instead of being global only
27
+
28
+ ### 2.2.0
29
+
30
+ - Proper connection closing and previous patches
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |gem|
4
4
  gem.name = "hiera-mysql-json-backend-jruby"
5
- gem.version = "2.0.0"
5
+ gem.version = "2.2.0"
6
6
  gem.authors = ["Hostnet"]
7
7
  gem.email = ["opensource@hostnet.nl"]
8
8
  gem.description = %q{Alternative MySQL backend with json support for hiera}
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |gem|
4
4
  gem.name = "hiera-mysql-json-backend"
5
- gem.version = "2.0.0"
5
+ gem.version = "2.2.0"
6
6
  gem.authors = ["Hostnet"]
7
7
  gem.email = ["opensource@hostnet.nl"]
8
8
  gem.description = %q{Alternative MySQL backend with json support for hiera}
@@ -66,6 +66,9 @@ class Hiera
66
66
  mysql_pass = mysql_config.fetch(:pass, nil) || Config[:mysql_json][:pass]
67
67
  mysql_port = mysql_config.fetch(:port, nil) || Config[:mysql_json][:port] || '3306'
68
68
  mysql_database = mysql_config.fetch(:database, nil) || Config[:mysql_json][:database]
69
+ lookup_constraints = data.fetch(:only_for, nil) || Config[:mysql_json][:only_for] || {}
70
+
71
+ next unless should_lookup?(lookup_constraints, scope)
69
72
 
70
73
  connection_hash = {
71
74
  host: mysql_host,
@@ -92,23 +95,9 @@ class Hiera
92
95
  sqlvalue = sql_results[0]['value']
93
96
 
94
97
  begin
95
- new_answer = JSON.parse(sqlvalue)
98
+ new_answer = JSON.parse("{\"r\":#{sqlvalue}}")['r']
96
99
  rescue
97
100
  Hiera.debug("Miserable failure while parsing #{key} as JSON.")
98
- end
99
-
100
- if new_answer.nil?
101
- case sqlvalue
102
- when /^(true|t|yes|y|1)$/i
103
- new_answer = true
104
- when /^(false|f|no|n|0)$/i
105
- new_answer = false
106
- else
107
- Hiera.debug("Miserable failure while parsing #{key} as boolean.")
108
- end
109
- end
110
-
111
- if new_answer.nil?
112
101
  raise Exception, "Parse error for key '#{key}'. Offending data: #{sql_results[0]['value']}." unless Config[:mysql_json][:ignore_json_parse_errors]
113
102
  next
114
103
  end
@@ -163,7 +152,9 @@ class Hiera
163
152
  end
164
153
  data << row
165
154
  end
166
-
155
+ stmt.close
156
+ conn.close
157
+ data
167
158
  else
168
159
  client = Mysql2::Client.new(connection_hash)
169
160
  begin
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hiera-mysql-json-backend
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hostnet
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-09-07 00:00:00.000000000 Z
11
+ date: 2025-03-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mysql2
@@ -73,7 +73,7 @@ homepage: https://github.com/hostnet/hiera-mysql-json-backend
73
73
  licenses:
74
74
  - MIT
75
75
  metadata: {}
76
- post_install_message:
76
+ post_install_message:
77
77
  rdoc_options: []
78
78
  require_paths:
79
79
  - lib
@@ -88,9 +88,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
90
  requirements: []
91
- rubyforge_project:
92
- rubygems_version: 2.2.5
93
- signing_key:
91
+ rubygems_version: 3.3.27
92
+ signing_key:
94
93
  specification_version: 4
95
94
  summary: Alternative MySQL backend with json support for hiera
96
95
  test_files: []