kafo_parsers 1.1.0 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9de270f92023f0577232bb8165246fd6afc2da7bcc18992b8b979d178f19526b
4
- data.tar.gz: 7718b9cad1349e1a4800de3c360deaa13c87cbe7bc2c24fd11dbf50949cb6f7b
3
+ metadata.gz: 747520cf42c2a91caca542f85d2185620e75e291fb5cbaaa6e51bf7850868704
4
+ data.tar.gz: 556665c63d578dcc13e346a80413da96735be1fcf9df0294258e536ceff546e7
5
5
  SHA512:
6
- metadata.gz: dba6b56a64cbdfe15b137e08cf6d79d4ab488c8fc6a3c980070a43fe75995cd61404f8119401073522aa589ba6dee5922fcc4705d0186c9c57f8c8fe6007f602
7
- data.tar.gz: 8b5a282f6aa2c30a6a7ade395b27c0142c134ea9f703a87dc83b9abd42ef8805aed9b6bed70d1779a1880de837af700fd222976ad83efe48c09a318eef5184a1
6
+ metadata.gz: 92bb6e4a7c67b7a28c8834bfa702b56a87a538aa0e0055a7348369e3ef1d934a35fa6331c0758623aade6d427edc7a40a699b0c15ae282086b078e58f7479b11
7
+ data.tar.gz: 41ebd83a1ce35095dbd5206d6bfc27bd9d45499c77e32a96846330fda95f949a92343a3e802d13e60c17b3f8464e34a062e2139b278e293fd72a6d18d8dc32d9
@@ -133,10 +133,30 @@ module KafoParsers
133
133
 
134
134
  private
135
135
 
136
+ def self.search_puppet_path(bin_name)
137
+ # Find the location of the puppet executable and use that to
138
+ # determine the path of all executables
139
+ bin_path = (::ENV['PATH'].split(File::PATH_SEPARATOR) + ['/opt/puppetlabs/bin']).find do |path|
140
+ File.executable?(File.join(path, 'puppet')) && File.executable?(File.join(path, bin_name))
141
+ end
142
+ File.join([bin_path, bin_name].compact)
143
+ end
144
+
145
+ def self.is_aio_puppet?
146
+ puppet_command = search_puppet_path('puppet')
147
+ File.realpath(puppet_command).start_with?('/opt/puppetlabs')
148
+ rescue Errno::ENOENT
149
+ false
150
+ end
151
+
136
152
  def self.run_puppet(command)
137
- env_vars = self.puppet_bin.start_with?('/opt/puppetlabs') ? clean_env_vars : ::ENV
138
153
  command = command.unshift(self.puppet_bin)
139
- Open3.capture3(env_vars, *command, :unsetenv_others => true)
154
+
155
+ if is_aio_puppet?
156
+ Open3.capture3(clean_env_vars, *command, :unsetenv_others => true)
157
+ else
158
+ Open3.capture3(::ENV, *command, :unsetenv_others => false)
159
+ end
140
160
  end
141
161
 
142
162
  def self.clean_env_vars
@@ -153,10 +173,21 @@ module KafoParsers
153
173
  #
154
174
  # values are reported as strings which is issue especially for :under
155
175
  # strings are double quoted
176
+ # basic array and hashes are supported
156
177
  # others must be typecast manually according to reported type
157
178
  def sanitize(value)
158
179
  if (value.start_with?("'") && value.end_with?("'")) || (value.start_with?('"') && value.end_with?('"'))
159
180
  value = value[1..-2]
181
+ elsif value.start_with?('[') && value.end_with?(']')
182
+ # TODO: handle commas in strings like ["a,b", "c"]
183
+ value = value[1..-2].split(',').map { |v| sanitize(v.strip) }
184
+ elsif value.start_with?('{') && value.end_with?('}')
185
+ # TODO: handle commas and => in strings, like {"key" => "value,=>"}
186
+ value = value[1..-2].split(',').map do |v|
187
+ split = v.strip.split('=>')
188
+ raise 'Invalid hash' unless split.length == 2
189
+ split.map { |s| sanitize(s.strip) }
190
+ end.to_h
160
191
  end
161
192
  value = :undef if value == 'undef'
162
193
 
@@ -1,3 +1,3 @@
1
1
  module KafoParsers
2
- VERSION = "1.1.0"
2
+ VERSION = "1.2.1"
3
3
  end
metadata CHANGED
@@ -1,29 +1,35 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kafo_parsers
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marek Hulan
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-03-25 00:00:00.000000000 Z
11
+ date: 2021-07-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.5'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '3'
20
23
  type: :development
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
- - - "~>"
27
+ - - ">="
25
28
  - !ruby/object:Gem::Version
26
29
  version: '1.5'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '3'
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: rake
29
35
  requirement: !ruby/object:Gem::Requirement
@@ -130,7 +136,7 @@ homepage: https://github.com/theforeman/kafo_parsers
130
136
  licenses:
131
137
  - GPL-3.0+
132
138
  metadata: {}
133
- post_install_message:
139
+ post_install_message:
134
140
  rdoc_options: []
135
141
  require_paths:
136
142
  - lib
@@ -145,9 +151,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
145
151
  - !ruby/object:Gem::Version
146
152
  version: '0'
147
153
  requirements: []
148
- rubyforge_project:
149
- rubygems_version: 2.7.6.2
150
- signing_key:
154
+ rubygems_version: 3.1.6
155
+ signing_key:
151
156
  specification_version: 4
152
157
  summary: Puppet module parsers
153
158
  test_files: []