kafo_parsers 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/kafo_parsers/puppet_strings_module_parser.rb +26 -7
- data/lib/kafo_parsers/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9de270f92023f0577232bb8165246fd6afc2da7bcc18992b8b979d178f19526b
|
4
|
+
data.tar.gz: 7718b9cad1349e1a4800de3c360deaa13c87cbe7bc2c24fd11dbf50949cb6f7b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dba6b56a64cbdfe15b137e08cf6d79d4ab488c8fc6a3c980070a43fe75995cd61404f8119401073522aa589ba6dee5922fcc4705d0186c9c57f8c8fe6007f602
|
7
|
+
data.tar.gz: 8b5a282f6aa2c30a6a7ade395b27c0142c134ea9f703a87dc83b9abd42ef8805aed9b6bed70d1779a1880de837af700fd222976ad83efe48c09a318eef5184a1
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
require 'json'
|
3
|
+
require 'open3'
|
4
|
+
|
3
5
|
require 'kafo_parsers/doc_parser'
|
4
6
|
require 'kafo_parsers/param_doc_parser'
|
5
7
|
|
@@ -25,11 +27,11 @@ module KafoParsers
|
|
25
27
|
end
|
26
28
|
|
27
29
|
def self.available?
|
28
|
-
|
29
|
-
if
|
30
|
+
_stdout, _stderr, status = run_puppet(['help', 'strings'])
|
31
|
+
if status.success?
|
30
32
|
return true
|
31
33
|
else
|
32
|
-
raise KafoParsers::ParserNotAvailable.new("#{puppet_bin} does not have strings module installed")
|
34
|
+
raise KafoParsers::ParserNotAvailable.new("#{puppet_bin} does not have strings module installed.")
|
33
35
|
end
|
34
36
|
end
|
35
37
|
|
@@ -37,10 +39,11 @@ module KafoParsers
|
|
37
39
|
@file = file = File.expand_path(file)
|
38
40
|
raise KafoParsers::ModuleName, "File not found #{file}, check your answer file" unless File.exist?(file)
|
39
41
|
|
40
|
-
command =
|
41
|
-
@raw_json =
|
42
|
-
|
43
|
-
|
42
|
+
command = ['strings', 'generate', '--format', 'json', file]
|
43
|
+
@raw_json, stderr, status = self.class.run_puppet(command)
|
44
|
+
|
45
|
+
unless status.success?
|
46
|
+
raise KafoParsers::ParseError, "'#{command}' returned error:\n #{@raw_json}\n #{stderr}"
|
44
47
|
end
|
45
48
|
|
46
49
|
begin
|
@@ -130,6 +133,22 @@ module KafoParsers
|
|
130
133
|
|
131
134
|
private
|
132
135
|
|
136
|
+
def self.run_puppet(command)
|
137
|
+
env_vars = self.puppet_bin.start_with?('/opt/puppetlabs') ? clean_env_vars : ::ENV
|
138
|
+
command = command.unshift(self.puppet_bin)
|
139
|
+
Open3.capture3(env_vars, *command, :unsetenv_others => true)
|
140
|
+
end
|
141
|
+
|
142
|
+
def self.clean_env_vars
|
143
|
+
# Cleaning ENV vars and keeping required vars only because,
|
144
|
+
# When using SCL it adds GEM_HOME and GEM_PATH ENV vars.
|
145
|
+
whitelisted_vars = %w[HOME USER LANG]
|
146
|
+
|
147
|
+
cleaned_env = ::ENV.select { |var| whitelisted_vars.include?(var) || var.start_with?('LC_') }
|
148
|
+
cleaned_env['PATH'] = '/sbin:/bin:/usr/sbin:/usr/bin:/opt/puppetlabs/bin'
|
149
|
+
cleaned_env
|
150
|
+
end
|
151
|
+
|
133
152
|
# default values using puppet strings includes $ symbol, e.g. "$::foreman::params::ssl"
|
134
153
|
#
|
135
154
|
# values are reported as strings which is issue especially for :under
|
data/lib/kafo_parsers/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kafo_parsers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marek Hulan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-03-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -146,7 +146,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
146
146
|
version: '0'
|
147
147
|
requirements: []
|
148
148
|
rubyforge_project:
|
149
|
-
rubygems_version: 2.7.6
|
149
|
+
rubygems_version: 2.7.6.2
|
150
150
|
signing_key:
|
151
151
|
specification_version: 4
|
152
152
|
summary: Puppet module parsers
|