puppet-debugger 0.12.3 → 0.13.0
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
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 4beafaf71c6a05b596dc06a3c684dea8cfc91bff8a840d28938bf3e0e7229307
|
4
|
+
data.tar.gz: 01cd85bee83b96d48a3631c87478458afeb2821a8bf2592fecc5226261719329
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5a7dd471bdccd178422b141cc01f537004b401b3c31c26dd6559d5d6d9f7b49220205c381e8c2e1dcef1e4b3c1d71a1a2d7baaddc5a4ecde59c9112e02493b17
|
7
|
+
data.tar.gz: 0adf4abdef26c817c780ddcb9e9acd9add6f02b616736daf0cd6238d49eafef240f5d28a741f35babb01c7e6c0c852855da8b9090528c11f6999c8e5e55b8ac4
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
## Unreleased
|
2
2
|
|
3
|
+
## 0.13.0
|
4
|
+
|
5
|
+
- Fixes gh-66 - colon symbol vanishing from variable output
|
6
|
+
- Adds ability to send content as an option at start
|
7
|
+
- Fixes issue where stack traces where not being shown
|
8
|
+
- Ensure output goes to proper buffer
|
9
|
+
|
3
10
|
## 0.12.3
|
4
11
|
|
5
12
|
- Fixes incorrect puppet namespace when list functions again
|
@@ -53,8 +53,8 @@ module AwesomePrint
|
|
53
53
|
else
|
54
54
|
h = object.to_hash.merge(name: object.name, title: object.title)
|
55
55
|
end
|
56
|
-
res_str = awesome_hash(h)
|
57
|
-
"#{object.class} #{res_str
|
56
|
+
res_str = awesome_hash(JSON.parse(h.to_json)) #converting to json removes symbols
|
57
|
+
"#{object.class} #{res_str}"
|
58
58
|
end
|
59
59
|
end
|
60
60
|
end
|
@@ -1,44 +1,44 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
3
|
+
require "puppet/application"
|
4
|
+
require "optparse"
|
5
|
+
require "puppet/util/command_line"
|
6
6
|
|
7
7
|
class Puppet::Application::Debugger < Puppet::Application
|
8
8
|
attr_reader :use_stdin
|
9
9
|
|
10
|
-
option(
|
10
|
+
option("--execute EXECUTE", "-e") do |arg|
|
11
11
|
options[:code] = arg
|
12
12
|
end
|
13
13
|
|
14
|
-
option(
|
14
|
+
option("--facterdb-filter FILTER") do |arg|
|
15
15
|
options[:use_facterdb] = true unless options[:node_name]
|
16
|
-
ENV[
|
16
|
+
ENV["DEBUGGER_FACTERDB_FILTER"] = arg if arg
|
17
17
|
end
|
18
18
|
|
19
|
-
option(
|
19
|
+
option("--test") do |_arg|
|
20
20
|
options[:quiet] = true
|
21
21
|
options[:run_once] = true
|
22
22
|
@use_stdin = true
|
23
23
|
end
|
24
24
|
|
25
|
-
option(
|
25
|
+
option("--no-facterdb") { |_arg| options[:use_facterdb] = false }
|
26
26
|
|
27
|
-
option(
|
27
|
+
option("--log-level LEVEL", "-l") do |arg|
|
28
28
|
Puppet::Util::Log.level = arg.to_sym
|
29
29
|
end
|
30
30
|
|
31
|
-
option(
|
31
|
+
option("--quiet", "-q") { |_arg| options[:quiet] = true }
|
32
32
|
|
33
|
-
option(
|
33
|
+
option("--play URL", "-p") do |arg|
|
34
34
|
options[:play] = arg
|
35
35
|
end
|
36
36
|
|
37
|
-
option(
|
37
|
+
option("--stdin", "-s") { |_arg| @use_stdin = true }
|
38
38
|
|
39
|
-
option(
|
39
|
+
option("--run-once", "-r") { |_arg| options[:run_once] = true }
|
40
40
|
|
41
|
-
option(
|
41
|
+
option("--node-name CERTNAME", "-n") do |arg|
|
42
42
|
options[:use_facterdb] = false
|
43
43
|
options[:node_name] = arg
|
44
44
|
end
|
@@ -178,9 +178,9 @@ Copyright (c) 2019 NWOps
|
|
178
178
|
@options = { use_facterdb: true, play: nil, run_once: false, node_name: nil, quiet: false, help: false, scope: nil }
|
179
179
|
@use_stdin = false
|
180
180
|
begin
|
181
|
-
require
|
181
|
+
require "puppet-debugger"
|
182
182
|
rescue LoadError => e
|
183
|
-
Puppet.err(
|
183
|
+
Puppet.err("You must install the puppet-debugger: gem install puppet-debugger")
|
184
184
|
end
|
185
185
|
end
|
186
186
|
|
@@ -191,40 +191,45 @@ Copyright (c) 2019 NWOps
|
|
191
191
|
|
192
192
|
if options[:code]
|
193
193
|
code_input = options.delete(:code)
|
194
|
-
file = Tempfile.new([
|
195
|
-
File.open(file,
|
194
|
+
file = Tempfile.new(["puppet_repl_input", ".pp"])
|
195
|
+
File.open(file, "w") do |f|
|
196
196
|
f.write(code_input)
|
197
197
|
end
|
198
198
|
options[:play] = file
|
199
199
|
elsif command_line.args.empty? && use_stdin
|
200
200
|
code_input = STDIN.read
|
201
|
-
file = Tempfile.new([
|
202
|
-
File.open(file,
|
201
|
+
file = Tempfile.new(["puppet_repl_input", ".pp"])
|
202
|
+
File.open(file, "w") do |f|
|
203
203
|
f.write(code_input)
|
204
204
|
end
|
205
205
|
options[:play] = file
|
206
206
|
elsif !command_line.args.empty?
|
207
207
|
manifest = command_line.args.shift
|
208
208
|
raise "Could not find file #{manifest}" unless Puppet::FileSystem.exist?(manifest)
|
209
|
-
Puppet.warning("Only one file can be used per run. Skipping #{command_line.args.join(
|
209
|
+
Puppet.warning("Only one file can be used per run. Skipping #{command_line.args.join(", ")}") unless command_line.args.empty?
|
210
210
|
options[:play] = file
|
211
211
|
end
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
212
|
+
begin
|
213
|
+
if !options[:use_facterdb] && options[:node_name].nil?
|
214
|
+
debug_environment = create_environment(nil)
|
215
|
+
Puppet.notice('Gathering node facts...')
|
216
|
+
node = create_node(debug_environment)
|
217
|
+
scope = create_scope(node)
|
218
|
+
# start_debugger(scope)
|
219
|
+
options[:scope] = scope
|
220
|
+
end
|
221
|
+
::PuppetDebugger::Cli.start_without_stdin(options)
|
222
|
+
rescue Exception => e
|
223
|
+
puts e
|
224
|
+
exit 1
|
219
225
|
end
|
220
|
-
::PuppetDebugger::Cli.start_without_stdin(options)
|
221
226
|
end
|
222
227
|
|
223
228
|
def create_environment(manifest)
|
224
229
|
configured_environment = Puppet.lookup(:current_environment)
|
225
230
|
manifest ?
|
226
|
-
|
227
|
-
|
231
|
+
configured_environment.override_with(manifest: manifest) :
|
232
|
+
configured_environment
|
228
233
|
end
|
229
234
|
|
230
235
|
def create_node(environment)
|
@@ -237,7 +242,7 @@ Copyright (c) 2019 NWOps
|
|
237
242
|
Puppet[:node_name_value] = facts.values[Puppet[:node_name_fact]]
|
238
243
|
facts.name = Puppet[:node_name_value]
|
239
244
|
end
|
240
|
-
Puppet.override({ current_environment: environment },
|
245
|
+
Puppet.override({ current_environment: environment }, "For puppet debugger") do
|
241
246
|
# Find our Node
|
242
247
|
unless node = Puppet::Node.indirection.find(Puppet[:node_name_value])
|
243
248
|
raise "Could not find node #{Puppet[:node_name_value]}"
|
@@ -268,7 +273,7 @@ Copyright (c) 2019 NWOps
|
|
268
273
|
# options[:source_file], options[:source_line] = stacktrace.last
|
269
274
|
::PuppetRepl::Cli.start(options)
|
270
275
|
else
|
271
|
-
Puppet.info
|
276
|
+
Puppet.info "puppet debug: refusing to start the debugger without a tty"
|
272
277
|
end
|
273
278
|
end
|
274
279
|
|
data/lib/puppet-debugger/cli.rb
CHANGED
@@ -31,6 +31,8 @@ module PuppetDebugger
|
|
31
31
|
@source_file = options[:source_file] || nil
|
32
32
|
@source_line_num = options[:source_line] || nil
|
33
33
|
@in_buffer = options[:in_buffer] || $stdin
|
34
|
+
Readline.input = @in_buffer
|
35
|
+
Readline.output = @out_buffer
|
34
36
|
Readline.completion_append_character = ""
|
35
37
|
Readline.basic_word_break_characters = " "
|
36
38
|
Readline.completion_proc = command_completion
|
@@ -236,11 +238,18 @@ or "help" to show the help screen.
|
|
236
238
|
# or
|
237
239
|
# this is primarily used by the debug::break() module function and the puppet debugger face
|
238
240
|
# @param [Hash] must contain at least the puppet scope object
|
239
|
-
# @option play - must be a path
|
241
|
+
# @option play [String] - must be a path to a file
|
242
|
+
# @option content [String] - play back the string content passed in
|
243
|
+
# @option source_file [String] - the file from which the breakpoint was used
|
244
|
+
# @option source_line [Integer] - the line in the sourcefile from which the breakpoint was used
|
245
|
+
# @option in_buffer [IO] - the input buffer to read from
|
246
|
+
# @option out_buffer [IO] - the output buffer to write to
|
247
|
+
# @option scope [Scope] - the puppet scope
|
240
248
|
def self.start_without_stdin(options = { scope: nil })
|
241
|
-
puts print_repl_desc unless options[:quiet]
|
242
|
-
repl_obj = PuppetDebugger::Cli.new(options)
|
243
249
|
options[:play] = options[:play].path if options[:play].respond_to?(:path)
|
250
|
+
repl_obj = PuppetDebugger::Cli.new(options)
|
251
|
+
repl_obj.out_buffer.puts print_repl_desc unless options[:quiet]
|
252
|
+
repl_obj.handle_input(options[:content]) if options[:content]
|
244
253
|
# TODO: make the output optional so we can have different output destinations
|
245
254
|
repl_obj.handle_input("whereami") if options[:source_file] && options[:source_line]
|
246
255
|
repl_obj.handle_input("play #{options[:play]}") if options[:play]
|
@@ -259,9 +268,9 @@ or "help" to show the help screen.
|
|
259
268
|
opt :quiet, "Do not display banner", required: false, default: false
|
260
269
|
end
|
261
270
|
options = opts.merge(options)
|
262
|
-
puts print_repl_desc unless options[:quiet]
|
263
271
|
options[:play] = options[:play].path if options[:play].respond_to?(:path)
|
264
272
|
repl_obj = PuppetDebugger::Cli.new(options)
|
273
|
+
repl_obj.out_buffer.puts print_repl_desc unless options[:quiet]
|
265
274
|
if options[:play]
|
266
275
|
repl_obj.handle_input("play #{options[:play]}")
|
267
276
|
elsif ARGF.filename != "-"
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'awesome_print'
|
3
|
+
require "awesome_print/ext/awesome_puppet"
|
4
|
+
|
5
|
+
RSpec.describe do
|
6
|
+
let(:output) do
|
7
|
+
StringIO.new
|
8
|
+
end
|
9
|
+
|
10
|
+
let(:debugger) do
|
11
|
+
PuppetDebugger::Cli.new(options)
|
12
|
+
end
|
13
|
+
|
14
|
+
let(:options) do
|
15
|
+
{
|
16
|
+
out_buffer: output
|
17
|
+
}
|
18
|
+
end
|
19
|
+
|
20
|
+
let(:input) do
|
21
|
+
"notify{'ff:gg': }"
|
22
|
+
end
|
23
|
+
|
24
|
+
let(:resource_type) do
|
25
|
+
debugger.parser.evaluate_string(debugger.scope, input).first
|
26
|
+
end
|
27
|
+
|
28
|
+
let(:ral_type) do
|
29
|
+
debugger.scope.catalog.resource(resource_type.type_name, resource_type.title).to_ral
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'outputs awesomely' do
|
33
|
+
expect(ral_type.ai).to include('ff:gg')
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
end
|
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.13.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-
|
11
|
+
date: 2019-08-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: table_print
|
@@ -193,6 +193,7 @@ files:
|
|
193
193
|
- lib/puppet/application/debugger.rb
|
194
194
|
- puppet-debugger.gemspec
|
195
195
|
- run_container_test.sh
|
196
|
+
- spec/awesome_print/ext/awesome_puppet_spec.rb
|
196
197
|
- spec/environment_spec.rb
|
197
198
|
- spec/facts_spec.rb
|
198
199
|
- spec/fixtures/environments/production/manifests/site.pp
|
@@ -286,8 +287,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
286
287
|
- !ruby/object:Gem::Version
|
287
288
|
version: '0'
|
288
289
|
requirements: []
|
289
|
-
|
290
|
-
rubygems_version: 2.6.14.3
|
290
|
+
rubygems_version: 3.0.3
|
291
291
|
signing_key:
|
292
292
|
specification_version: 4
|
293
293
|
summary: A repl based debugger for the puppet language
|