puppet-debugger 0.4.4 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.dockerignore +5 -0
- data/.gitignore +3 -0
- data/.rubocop_todo.yml +1 -1
- data/CHANGELOG.md +12 -0
- data/Gemfile +2 -4
- data/Gemfile.lock +26 -15
- data/README.md +31 -24
- data/lib/puppet-debugger/cli.rb +6 -5
- data/lib/puppet-debugger/support.rb +4 -27
- data/lib/puppet-debugger/support/compiler.rb +1 -1
- data/lib/puppet-debugger/support/environment.rb +32 -5
- data/lib/puppet-debugger/support/functions.rb +4 -17
- data/lib/puppet-debugger/support/input_responders.rb +1 -0
- data/lib/puppet-debugger/support/loader.rb +34 -0
- data/lib/puppet-debugger/support/node.rb +21 -0
- data/lib/puppet-debugger/support/scope.rb +9 -8
- data/lib/puppet/application/debugger.rb +7 -19
- data/lib/trollop.rb +740 -739
- data/lib/version.rb +1 -1
- data/puppet-debugger.gemspec +5 -4
- data/spec/environment_spec.rb +22 -0
- data/spec/puppet/application/debugger_spec.rb +72 -17
- data/spec/puppet_debugger_spec.rb +7 -7
- data/spec/spec_helper.rb +4 -0
- metadata +8 -5
data/lib/version.rb
CHANGED
data/puppet-debugger.gemspec
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
|
2
2
|
require './lib/version'
|
3
|
+
require 'date'
|
3
4
|
|
4
5
|
Gem::Specification.new do |s|
|
5
6
|
s.name = "puppet-debugger"
|
@@ -17,8 +18,8 @@ Gem::Specification.new do |s|
|
|
17
18
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
18
19
|
s.require_paths = ["lib"]
|
19
20
|
s.authors = ["Corey Osman"]
|
20
|
-
s.date =
|
21
|
-
s.description = "A interactive command line tool for evaluating the puppet language"
|
21
|
+
s.date = DateTime.now.strftime('%Y-%m-%d')
|
22
|
+
s.description = "A interactive command line tool for evaluating and debugging the puppet language"
|
22
23
|
s.email = "corey@nwops.io"
|
23
24
|
s.extra_rdoc_files = [
|
24
25
|
"CHANGELOG.md",
|
@@ -28,9 +29,9 @@ Gem::Specification.new do |s|
|
|
28
29
|
s.homepage = "http://github.com/nwops/puppet-debugger"
|
29
30
|
s.licenses = ["MIT"]
|
30
31
|
s.rubygems_version = "2.4.5.1"
|
31
|
-
s.summary = "A repl for the puppet language"
|
32
|
+
s.summary = "A repl based debugger for the puppet language"
|
32
33
|
s.add_runtime_dependency(%q<puppet>, [">= 3.8"])
|
33
34
|
s.add_runtime_dependency(%q<facterdb>, [">= 0.3.8"])
|
34
35
|
s.add_runtime_dependency(%q<awesome_print>, ["~> 1.6"])
|
35
36
|
s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
|
36
|
-
end
|
37
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'spec_helper'
|
3
|
+
require 'stringio'
|
4
|
+
describe 'environment' do
|
5
|
+
let(:output) do
|
6
|
+
StringIO.new('', 'w')
|
7
|
+
end
|
8
|
+
|
9
|
+
let(:debugger) do
|
10
|
+
PuppetDebugger::Cli.new(out_buffer: output)
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'environment returns object with properties' do
|
14
|
+
expect(debugger.puppet_environment).to_not eq nil
|
15
|
+
expect(debugger.default_site_manifest).to eq(File.join(Puppet[:environmentpath],
|
16
|
+
Puppet[:environment], 'manifests', 'site.pp'))
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'full module path' do
|
20
|
+
expect(debugger.modules_paths.count).to be >= 2
|
21
|
+
end
|
22
|
+
end
|
@@ -6,7 +6,15 @@ require 'puppet/application/debugger'
|
|
6
6
|
|
7
7
|
describe Puppet::Application::Debugger do
|
8
8
|
let(:debugger) do
|
9
|
-
Puppet::Application
|
9
|
+
Puppet::Application::Debugger.new(command_line)
|
10
|
+
end
|
11
|
+
|
12
|
+
let(:args) do
|
13
|
+
[]
|
14
|
+
end
|
15
|
+
|
16
|
+
let(:command_line) do
|
17
|
+
Puppet::Util::CommandLine.new('debugger', args)
|
10
18
|
end
|
11
19
|
|
12
20
|
let(:environment) do
|
@@ -46,21 +54,68 @@ describe Puppet::Application::Debugger do
|
|
46
54
|
it 'shows describtion' do
|
47
55
|
expect(debugger.help).to match(/^puppet-debugger\([^\)]+\) -- (.*)$/)
|
48
56
|
end
|
57
|
+
describe 'with facterdb' do
|
58
|
+
before(:each) do
|
59
|
+
end
|
60
|
+
it 'run md5 function' do
|
61
|
+
allow(debugger).to receive(:options).and_return(code: "md5('sdafsd')", quiet: true, run_once: true, use_facterdb: true)
|
62
|
+
expect { debugger.run_command }.to output(/569ebc3d91672e7d3dce25de1684d0c9/).to_stdout
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'assign variable' do
|
66
|
+
allow(debugger).to receive(:options).and_return(code: "$var1 = 'blah'", quiet: true, run_once: true, use_facterdb: true)
|
67
|
+
expect { debugger.run_command }.to output(/"blah"/).to_stdout
|
68
|
+
end
|
69
|
+
|
70
|
+
describe 'can reset correctly' do
|
71
|
+
let(:input) do
|
72
|
+
<<-EOF
|
73
|
+
$var1 = 'dsfasd'
|
74
|
+
$var1
|
75
|
+
reset
|
76
|
+
$var1 = '111111'
|
77
|
+
$var1
|
78
|
+
EOF
|
79
|
+
end
|
80
|
+
|
81
|
+
|
82
|
+
it 'assign variable' do
|
83
|
+
allow(debugger).to receive(:options).and_return(code: input, quiet: true, run_once: true, use_facterdb: true)
|
84
|
+
expect { debugger.run_command }.to output(/\"111111\"/).to_stdout
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
describe 'without facterdb' do
|
90
|
+
before(:each) do
|
91
|
+
end
|
92
|
+
it 'run md5 function' do
|
93
|
+
allow(debugger).to receive(:options).and_return(code: "md5('sdafsd')", quiet: true, run_once: true, use_facterdb: false)
|
94
|
+
expect { debugger.run_command }.to output(/569ebc3d91672e7d3dce25de1684d0c9/).to_stdout
|
95
|
+
end
|
96
|
+
it 'assign variable' do
|
97
|
+
allow(debugger).to receive(:options).and_return(code: "$var1 = 'blah'", quiet: true, run_once: true, use_facterdb: false)
|
98
|
+
expect { debugger.run_command }.to output(/"blah"/).to_stdout
|
99
|
+
end
|
100
|
+
|
101
|
+
describe 'can reset correctly' do
|
102
|
+
let(:input) do
|
103
|
+
<<-EOF
|
104
|
+
$var1 = 'dsfasd'
|
105
|
+
$var1
|
106
|
+
reset
|
107
|
+
$var1 = '111111'
|
108
|
+
$var1
|
109
|
+
EOF
|
110
|
+
end
|
111
|
+
|
112
|
+
|
113
|
+
it 'assign variable' do
|
114
|
+
allow(debugger).to receive(:options).and_return(code: input, quiet: true, run_once: true, use_facterdb: false)
|
115
|
+
expect { debugger.run_command }.to output(/\"111111\"/).to_stdout
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
49
120
|
|
50
|
-
# use --stdin
|
51
|
-
# use facterdb
|
52
|
-
# not use facterdb
|
53
|
-
# use execute
|
54
|
-
# play
|
55
|
-
# runonce
|
56
|
-
# test
|
57
|
-
|
58
|
-
# it 'create a node' do
|
59
|
-
# require 'pry'; binding.pry
|
60
|
-
# expect(node).to be_a(Puppet::Node::Environment)
|
61
|
-
# end
|
62
|
-
#
|
63
|
-
# it 'create a scope' do
|
64
|
-
# expect(scope).to be_a(Puppet::Node::Environment)
|
65
|
-
# end
|
66
121
|
end
|
@@ -59,21 +59,21 @@ describe 'PuppetDebugger' do
|
|
59
59
|
describe 'native definitions' do
|
60
60
|
describe 'create' do
|
61
61
|
let(:input) do
|
62
|
-
'define
|
62
|
+
'define testfoodefine {}'
|
63
63
|
end
|
64
64
|
let(:debugger_output) do
|
65
65
|
"\n => Puppet::Type::Component {\n loglevel\e[0;37m => \e[0m\e[0;36mnotice\e[0m,\n name\e[0;37m => \e[0m\e[0;33m\"some_name\"\e[0m,\n title\e[0;37m => \e[0m\e[0;33m\"Testfoo[some_name]\"\e[0m\n}\n"
|
66
66
|
end
|
67
67
|
it do
|
68
68
|
debugger.handle_input(input)
|
69
|
-
expect(debugger.scope.environment.known_resource_types.definitions.keys).to include('
|
69
|
+
expect(debugger.scope.environment.known_resource_types.definitions.keys).to include('testfoodefine')
|
70
70
|
expect(output.string).to eq("\n")
|
71
71
|
end
|
72
72
|
it do
|
73
73
|
debugger.handle_input(input)
|
74
|
-
debugger.handle_input("
|
74
|
+
debugger.handle_input("testfoodefine{'some_name':}")
|
75
75
|
expect(debugger.scope.compiler.resources.collect(&:name)).to include('some_name')
|
76
|
-
expect(debugger.scope.compiler.resources.collect(&:type)).to include('
|
76
|
+
expect(debugger.scope.compiler.resources.collect(&:type)).to include('Testfoodefine')
|
77
77
|
expect(output.string).to include("\n => Puppet::Type::Component")
|
78
78
|
end
|
79
79
|
end
|
@@ -122,13 +122,13 @@ describe 'PuppetDebugger' do
|
|
122
122
|
expect(output.string).to eq("\n => String\n")
|
123
123
|
end
|
124
124
|
end
|
125
|
-
describe 'Array' do
|
125
|
+
describe 'Array', type_function: true do
|
126
126
|
let(:input) do
|
127
|
-
'
|
127
|
+
'type([1,2,3,4])'
|
128
128
|
end
|
129
129
|
it 'shows type' do
|
130
130
|
debugger.handle_input(input)
|
131
|
-
expect(output.string).to eq("\n => Tuple[Integer[1, 1], Integer[2, 2], Integer[3, 3], Integer[4, 4]]\n")
|
131
|
+
expect(output.string).to eq("\n => Tuple[Integer[1, 1], Integer[2, 2], Integer[3, 3], Integer[4, 4]]\n") if supports_type_function?
|
132
132
|
end
|
133
133
|
end
|
134
134
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -53,6 +53,10 @@ def supports_native_functions?
|
|
53
53
|
Gem::Version.new(Puppet.version) >= Gem::Version.new('4.3')
|
54
54
|
end
|
55
55
|
|
56
|
+
def supports_type_function?
|
57
|
+
Gem::Version.new(Puppet.version) >= Gem::Version.new('4.0')
|
58
|
+
end
|
59
|
+
|
56
60
|
RSpec.configure do |config|
|
57
61
|
config.filter_run_excluding native_functions: !supports_native_functions?
|
58
62
|
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.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Corey Osman
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-03-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: puppet
|
@@ -66,7 +66,8 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '3.12'
|
69
|
-
description: A interactive command line tool for evaluating the puppet
|
69
|
+
description: A interactive command line tool for evaluating and debugging the puppet
|
70
|
+
language
|
70
71
|
email: corey@nwops.io
|
71
72
|
executables:
|
72
73
|
- pdb
|
@@ -107,6 +108,7 @@ files:
|
|
107
108
|
- lib/puppet-debugger/support/facts.rb
|
108
109
|
- lib/puppet-debugger/support/functions.rb
|
109
110
|
- lib/puppet-debugger/support/input_responders.rb
|
111
|
+
- lib/puppet-debugger/support/loader.rb
|
110
112
|
- lib/puppet-debugger/support/node.rb
|
111
113
|
- lib/puppet-debugger/support/play.rb
|
112
114
|
- lib/puppet-debugger/support/scope.rb
|
@@ -115,6 +117,7 @@ files:
|
|
115
117
|
- lib/version.rb
|
116
118
|
- puppet-debugger.gemspec
|
117
119
|
- run_container_test.sh
|
120
|
+
- spec/environment_spec.rb
|
118
121
|
- spec/facts_spec.rb
|
119
122
|
- spec/fixtures/environments/production/manifests/site.pp
|
120
123
|
- spec/fixtures/invalid_node_obj.yaml
|
@@ -149,8 +152,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
149
152
|
version: '0'
|
150
153
|
requirements: []
|
151
154
|
rubyforge_project:
|
152
|
-
rubygems_version: 2.6.
|
155
|
+
rubygems_version: 2.6.11
|
153
156
|
signing_key:
|
154
157
|
specification_version: 4
|
155
|
-
summary: A repl for the puppet language
|
158
|
+
summary: A repl based debugger for the puppet language
|
156
159
|
test_files: []
|