puppet-debugger 0.11.0 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitlab-ci.yml +5 -5
- data/.ruby-version +1 -1
- data/CHANGELOG.md +5 -0
- data/lib/plugins/puppet-debugger/input_responders/vars.rb +29 -0
- data/lib/puppet-debugger/cli.rb +16 -12
- data/lib/puppet-debugger/version.rb +1 -1
- data/spec/input_responders/vars_spec.rb +17 -0
- data/spec/puppet_debugger_spec.rb +13 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e3a943d793cc70f63e92cffc0843d0f4e9dfee03
|
4
|
+
data.tar.gz: 892a71554b9c5e156de87363341c3ef04bc8cc7a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 35605789439801670e2899f17de1e10ef8109d6cb998ca6766993ba403dee1ab990a02faf0e43ae619f58c2d6ee2c83fa1b240d9eb9b88d51d2fce9011a8064e
|
7
|
+
data.tar.gz: bb774bc6493905d0fc280c09862e33462e4ea363c081d523b2ac2958f0f03e98a06d46f3593ad26b87e24380bed1131c9b7d233250890f1337069d94fd52613d
|
data/.gitlab-ci.yml
CHANGED
@@ -17,7 +17,7 @@ stages:
|
|
17
17
|
- ruby
|
18
18
|
|
19
19
|
web_trigger_staging:
|
20
|
-
|
20
|
+
stage: web_deploy
|
21
21
|
variables:
|
22
22
|
REF: staging
|
23
23
|
only:
|
@@ -37,7 +37,7 @@ rubocop_ruby:
|
|
37
37
|
- bundle exec rubocop -D
|
38
38
|
|
39
39
|
bump_and_tag:
|
40
|
-
|
40
|
+
stage: release
|
41
41
|
when: manual
|
42
42
|
tags:
|
43
43
|
- ruby2.2
|
@@ -76,7 +76,7 @@ bump_and_tag:
|
|
76
76
|
image: ruby:2.5
|
77
77
|
|
78
78
|
|
79
|
-
.
|
79
|
+
.ruby_26: &ruby26
|
80
80
|
image: ruby:2.6
|
81
81
|
|
82
82
|
gem_production:
|
@@ -133,8 +133,8 @@ puppet_60_ruby25:
|
|
133
133
|
<<: *puppet_job_def
|
134
134
|
<<: *ruby25
|
135
135
|
|
136
|
-
|
136
|
+
puppet_60_ruby26:
|
137
137
|
variables:
|
138
138
|
PUPPET_GEM_VERSION: "~> 6.4"
|
139
139
|
<<: *puppet_job_def
|
140
|
-
<<: *
|
140
|
+
<<: *ruby26
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.4
|
1
|
+
2.4.5
|
data/CHANGELOG.md
CHANGED
@@ -7,12 +7,41 @@ module PuppetDebugger
|
|
7
7
|
COMMAND_GROUP = :scope
|
8
8
|
|
9
9
|
def run(args = [])
|
10
|
+
filter = args
|
11
|
+
unless filter.empty?
|
12
|
+
parameters = resource_parameters(debugger.scope.catalog.resources, filter)
|
13
|
+
return parameters.ai(sort_keys: true, indent: -1)
|
14
|
+
end
|
10
15
|
# remove duplicate variables that are also in the facts hash
|
11
16
|
variables = debugger.scope.to_hash.delete_if { |key, _value| debugger.node.facts.values.key?(key) }
|
12
17
|
variables['facts'] = 'removed by the puppet-debugger' if variables.key?('facts')
|
13
18
|
output = 'Facts were removed for easier viewing'.ai + "\n"
|
14
19
|
output += variables.ai(sort_keys: true, indent: -1)
|
15
20
|
end
|
21
|
+
|
22
|
+
def resource_parameters(resources, filter = [])
|
23
|
+
find_resources(resources, filter).each_with_object({}) do | resource, acc|
|
24
|
+
name = "#{resource.type}[#{resource.name}]"
|
25
|
+
acc[name] = parameters_to_h(resource)
|
26
|
+
acc
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def parameters_to_h(resource)
|
31
|
+
resource.parameters.each_with_object({}) do | param, params |
|
32
|
+
name = param.first.to_s
|
33
|
+
params[name] = param.last.value
|
34
|
+
params
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def find_resources(resources, filter = [])
|
39
|
+
filter_string = filter.join(' ').downcase
|
40
|
+
resources.find_all do |resource|
|
41
|
+
resource.name.to_s.downcase.include?(filter_string) || resource.type.to_s.downcase.include?(filter_string)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
16
45
|
end
|
17
46
|
end
|
18
47
|
end
|
data/lib/puppet-debugger/cli.rb
CHANGED
@@ -93,25 +93,25 @@ module PuppetDebugger
|
|
93
93
|
# don't return anything or returns nil if item is not in the catalog
|
94
94
|
end
|
95
95
|
|
96
|
-
#
|
96
|
+
#
|
97
|
+
# @return [Array] - returns a formatted array
|
98
|
+
# @param types [Array] - an array or string
|
97
99
|
def expand_resource_type(types)
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
end
|
104
|
-
end
|
105
|
-
output
|
100
|
+
Array(types).flatten.map { |t| contains_resources?(t) ? to_resource_declaration(t) : t }
|
101
|
+
end
|
102
|
+
|
103
|
+
def contains_resources?(result)
|
104
|
+
! Array(result).flatten.find {|r| r.class.to_s =~ /Puppet::Pops::Types/ }.nil?
|
106
105
|
end
|
107
106
|
|
108
107
|
def normalize_output(result)
|
109
|
-
if
|
108
|
+
if contains_resources?(result)
|
110
109
|
output = expand_resource_type(result)
|
110
|
+
# the results might be wrapped into an array
|
111
|
+
# if the only output is a resource then return it
|
112
|
+
# otherwise it is multiple items or an actually array
|
111
113
|
return output.first if output.count == 1
|
112
114
|
return output
|
113
|
-
elsif result.class.to_s =~ /Puppet::Pops::Types/
|
114
|
-
return to_resource_declaration(result)
|
115
115
|
end
|
116
116
|
result
|
117
117
|
end
|
@@ -161,6 +161,10 @@ module PuppetDebugger
|
|
161
161
|
exit 1 # this can sometimes causes tests to fail
|
162
162
|
rescue PuppetDebugger::Exception::Error => e
|
163
163
|
output = e.message.fatal
|
164
|
+
rescue RuntimeException => e
|
165
|
+
output = e.message.fatal
|
166
|
+
out_buffer.puts output
|
167
|
+
exit 1
|
164
168
|
end
|
165
169
|
unless output.empty?
|
166
170
|
out_buffer.print ' => '
|
@@ -35,4 +35,21 @@ describe :vars do
|
|
35
35
|
expect(plugin.run(args)).to match(debugger_output)
|
36
36
|
end
|
37
37
|
end
|
38
|
+
|
39
|
+
describe 'list variables' do
|
40
|
+
let(:input) do
|
41
|
+
<<-EOF
|
42
|
+
class test( $param1 = "files", $param2 = $param1 ) {}
|
43
|
+
include test
|
44
|
+
EOF
|
45
|
+
end
|
46
|
+
it 'ls test' do
|
47
|
+
debugger.handle_input(input)
|
48
|
+
out = plugin.run(['test'])
|
49
|
+
expect(out).to include('"param1"')
|
50
|
+
expect(out).to include('"param2"')
|
51
|
+
end
|
52
|
+
|
53
|
+
|
54
|
+
end
|
38
55
|
end
|
@@ -225,11 +225,23 @@ describe 'PuppetDebugger' do
|
|
225
225
|
it 'shows type' do
|
226
226
|
if Gem::Version.new(Puppet.version) > Gem::Version.new('4.4')
|
227
227
|
debugger.handle_input(input)
|
228
|
-
expect(output.string
|
228
|
+
expect(output.string.strip.split("\n").count).to eq(6)
|
229
229
|
end
|
230
230
|
end
|
231
231
|
end
|
232
232
|
|
233
|
+
describe 'multi diemension array' do
|
234
|
+
let(:input) do
|
235
|
+
'[[1, [23,4], [22], [1,[2232]]]]'
|
236
|
+
end
|
237
|
+
|
238
|
+
it 'handles multi array' do
|
239
|
+
debugger.handle_input(input)
|
240
|
+
expect(output.string.count('[')).to eq(17)
|
241
|
+
end
|
242
|
+
|
243
|
+
end
|
244
|
+
|
233
245
|
describe 'command_completion' do
|
234
246
|
it 'should complete on tabs' do
|
235
247
|
allow(Readline).to receive(:line_buffer).and_return("\n")
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: puppet-debugger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.12.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Corey Osman
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-05-
|
11
|
+
date: 2019-05-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: table_print
|
@@ -286,7 +286,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
286
286
|
- !ruby/object:Gem::Version
|
287
287
|
version: '0'
|
288
288
|
requirements: []
|
289
|
-
|
289
|
+
rubyforge_project:
|
290
|
+
rubygems_version: 2.6.14.3
|
290
291
|
signing_key:
|
291
292
|
specification_version: 4
|
292
293
|
summary: A repl based debugger for the puppet language
|