puppet-debugger 0.8.1 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitlab-ci.yml +16 -10
- data/CHANGELOG.md +6 -0
- data/Gemfile +1 -1
- data/Plugin_development.md +2 -0
- data/README.md +40 -2
- data/lib/awesome_print/ext/awesome_puppet.rb +23 -3
- data/lib/plugins/puppet-debugger/input_responders/datatypes.rb +28 -3
- data/lib/puppet-debugger/cli.rb +2 -1
- data/lib/puppet-debugger/input_responder_plugin.rb +1 -1
- data/lib/puppet-debugger/support/loader.rb +0 -26
- data/lib/version.rb +1 -1
- data/puppet-debugger.gemspec +1 -1
- data/spec/input_responders/datatypes_spec.rb +8 -0
- data/spec/input_responders/vars_spec.rb +11 -0
- data/spec/puppet_debugger_spec.rb +10 -0
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 51ec604fd150c721a41a3d42ce21d69d3f9fed03
|
4
|
+
data.tar.gz: b75d1fd7d668e3264748315e724a139575a2cb38
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a294ae4f12955ff934f4c17ae4bd7b936647edae7f6972109d5a48a7715ca479daf61fabaa7f6369b44bfae010fec64f8393dab4c00d8ecc57f7bf36a7c40c2e
|
7
|
+
data.tar.gz: 5ee9828762a15965f4e61060fb9ce234c36da925b25277b8fa4030d4b2dc88730dffd7490b948d5b8adee4c7b1aa233eee653874d4e52cf3b9df7b82030ceafa
|
data/.gitlab-ci.yml
CHANGED
@@ -154,26 +154,32 @@ puppet_47_ruby22:
|
|
154
154
|
<<: *puppet_job_def
|
155
155
|
<<: *ruby22
|
156
156
|
|
157
|
-
|
157
|
+
puppet_410_ruby24:
|
158
158
|
variables:
|
159
|
-
PUPPET_GEM_VERSION: "~> 4.
|
159
|
+
PUPPET_GEM_VERSION: "~> 4.10.0"
|
160
160
|
<<: *puppet_job_def
|
161
|
-
<<: *
|
161
|
+
<<: *ruby24
|
162
162
|
|
163
|
-
|
163
|
+
puppet_50_ruby24:
|
164
164
|
variables:
|
165
|
-
PUPPET_GEM_VERSION: "~>
|
165
|
+
PUPPET_GEM_VERSION: "~> 5.0"
|
166
166
|
<<: *puppet_job_def
|
167
|
-
<<: *
|
167
|
+
<<: *ruby24
|
168
168
|
|
169
|
-
|
169
|
+
puppet_51_ruby24:
|
170
170
|
variables:
|
171
|
-
PUPPET_GEM_VERSION: "~>
|
171
|
+
PUPPET_GEM_VERSION: "~> 5.1"
|
172
172
|
<<: *puppet_job_def
|
173
173
|
<<: *ruby24
|
174
174
|
|
175
|
-
|
175
|
+
puppet_52_ruby24:
|
176
176
|
variables:
|
177
|
-
PUPPET_GEM_VERSION: "~> 5.
|
177
|
+
PUPPET_GEM_VERSION: "~> 5.2"
|
178
|
+
<<: *puppet_job_def
|
179
|
+
<<: *ruby24
|
180
|
+
|
181
|
+
puppet_53_ruby24:
|
182
|
+
variables:
|
183
|
+
PUPPET_GEM_VERSION: "~> 5.3"
|
178
184
|
<<: *puppet_job_def
|
179
185
|
<<: *ruby24
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
## Unreleased
|
2
2
|
|
3
|
+
## 0.9.0
|
4
|
+
Released October 24, 2017
|
5
|
+
* Adds FacterDB as 0.4.0 dependency for external facts support
|
6
|
+
* Fixes #59 - Unhandled puppet type with awesome_print
|
7
|
+
* Fixes loading of multiple data types
|
8
|
+
* Add Puppet 5.1, 5.2, 5.3 to test matrix
|
3
9
|
## 0.8.1
|
4
10
|
* Fixes bug with command completion and blank inputs
|
5
11
|
## 0.8.0
|
data/Gemfile
CHANGED
data/Plugin_development.md
CHANGED
@@ -200,6 +200,8 @@ Objects exposed that you might want access to:
|
|
200
200
|
* compiler (The puppet compiler object)
|
201
201
|
* catalog (The puppet catalog)
|
202
202
|
* function_map (Current map of functions)
|
203
|
+
* loaders ( The puppet loaders )
|
204
|
+
* puppet_environment
|
203
205
|
* add_hook, delete_hook
|
204
206
|
* handle_input (use instead of debugger.handle_input)
|
205
207
|
|
data/README.md
CHANGED
@@ -55,7 +55,7 @@ useful for other people.
|
|
55
55
|
https://github.com/nwops/puppet-debugger-demo
|
56
56
|
|
57
57
|
## Web demo
|
58
|
-
There is a web version of the [puppet-debugger](https://
|
58
|
+
There is a web version of the [puppet-debugger](https://demo.puppet-debugger.com) online but is somewhat
|
59
59
|
limited at this time. In the future we will be adding lots of awesome features to the web debugger.
|
60
60
|
|
61
61
|
## Usage
|
@@ -239,7 +239,45 @@ depending on the puppet version currently running.
|
|
239
239
|
|
240
240
|
You can display the current facterdb filter by running `facterdb_filter` from the debugger session.
|
241
241
|
|
242
|
-
Why do facter versions matter? While facter and puppet work independently just fine, newer forge modules utilize certain data structures found only in newer versions of facter.
|
242
|
+
Why do facter versions matter? While facter and puppet work independently just fine, newer forge modules utilize certain data structures found only in newer versions of facter.
|
243
|
+
So its really up to the puppet code you use. With facter 3, almost every fact is now a data structure. So if you are having issues with facts not existing in the debugger you may need to change the facter version `REPL_FACTER_VERSION` to something different.
|
244
|
+
|
245
|
+
## Custom FacterDB Facts
|
246
|
+
As of FacterDB 0.4.0 we can now supply custom [external fact sets](https://github.com/camptocamp/facterdb#supplying-custom-external-facts) to facterDB.. This is a huge deal because you can take the facts from any system and play around with the fact data in the debugger. This makes the debugger appear as it was run on that system. Moreover, you can create shareable fact sets for your entire team. To use an external fact set you first need to grab the facts from the system you wish to "mock". This can be done with `puppet facts` or even puppetdb queries and then create a file with the values hash.
|
247
|
+
|
248
|
+
|
249
|
+
Take the values from the values hash only and place inside a new file.
|
250
|
+
```
|
251
|
+
{
|
252
|
+
"name": "macbook-pro-10.domain",
|
253
|
+
"values": {
|
254
|
+
"custom_datacenter_fact": "iceland",
|
255
|
+
"puppetversion": "5.3.2",
|
256
|
+
"architecture": "x86_64",
|
257
|
+
"kernel": "Darwin",
|
258
|
+
"domain": "domain"
|
259
|
+
}
|
260
|
+
}
|
261
|
+
|
262
|
+
```
|
263
|
+
|
264
|
+
This can be easily done if you have `jq` installed.
|
265
|
+
|
266
|
+
`puppet facts | jq '.values' > /tmp/custom_facts/datacenter_a/2.4/os_x.facts`
|
267
|
+
|
268
|
+
Once you have created a directory with one or more fact files you just need to set an environment variable to tell facterDB about the custom fact sets.
|
269
|
+
|
270
|
+
`export FACTERDB_SEARCH_PATHS="/tmp/custom_facts/"`
|
271
|
+
|
272
|
+
Now everytime you start the puppet debugger, facterDB will use these custom fact files
|
273
|
+
as part of the facterDB database. However, you will still need to provide a search filter that references your custom fact because there are over a thousand facterDB fact sets.
|
274
|
+
|
275
|
+
`puppet debugger --facterdb-filter 'custom_datacenter_fact=iceland'`
|
276
|
+
|
277
|
+
|
278
|
+
Alternatively you can bypass the internal facterDB database by setting `export FACTERDB_SKIP_DEFAULTDB=true` and force your custom facts to be the only facts facterDB uses.
|
279
|
+
|
280
|
+
*Note: when exporting facterDB environment variables you will also change the behavior for rspec_puppet_facts and other gems that also rely on facterDB. So please remember to unset the variables if not needed*
|
243
281
|
|
244
282
|
## Playback support
|
245
283
|
puppet-debugger now supports playing back files or urls and loading the content into the debugger session. This means if you want to start a debugger session from an existing file or url you can play the content back in the debugger.
|
@@ -1,5 +1,19 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
module Kernel
|
4
|
+
class Hash
|
5
|
+
def to_h
|
6
|
+
hash = extra_hash_attributes.dup
|
7
|
+
|
8
|
+
self.class.hash_attribute_names.each do |name|
|
9
|
+
hash[name] = __send__(name)
|
10
|
+
end
|
11
|
+
|
12
|
+
hash
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
3
17
|
module AwesomePrint
|
4
18
|
module Puppet
|
5
19
|
def self.included(base)
|
@@ -26,13 +40,19 @@ module AwesomePrint
|
|
26
40
|
|
27
41
|
def awesome_puppet_resource(object)
|
28
42
|
return '' if object.nil?
|
29
|
-
|
43
|
+
resource_object = object.to_ral
|
44
|
+
awesome_puppet_type(resource_object)
|
30
45
|
end
|
31
46
|
|
32
47
|
def awesome_puppet_type(object)
|
33
48
|
return '' if object.nil?
|
34
|
-
return object.to_s unless object.respond_to?(:name) && object.respond_to?(:title)
|
35
|
-
|
49
|
+
return object.to_s unless object.respond_to?(:name) && object.respond_to?(:title) && object.respond_to?(:to_hash)
|
50
|
+
if Array.new.respond_to?(:to_h)
|
51
|
+
# to_h is only supported in ruby 2.1+
|
52
|
+
h = object.to_hash.merge(name: object.name, title: object.title).sort.to_h
|
53
|
+
else
|
54
|
+
h = object.to_hash.merge(name: object.name, title: object.title)
|
55
|
+
end
|
36
56
|
res_str = awesome_hash(h)
|
37
57
|
"#{object.class} #{res_str.delete(':')}"
|
38
58
|
end
|
@@ -7,9 +7,34 @@ module PuppetDebugger
|
|
7
7
|
COMMAND_GROUP = :environment
|
8
8
|
|
9
9
|
def run(args = [])
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
all_data_types.sort.ai
|
11
|
+
end
|
12
|
+
|
13
|
+
# @return [Array[String]] - returns a list of all the custom data types found in all the modules in the environment
|
14
|
+
def environment_data_types
|
15
|
+
globs = debugger.puppet_environment.instance_variable_get(:@modulepath).map { |m| File.join(m, '**', 'types', '**', '*.pp') }
|
16
|
+
files = globs.map { |g| Dir.glob(g) }.flatten
|
17
|
+
files.map do |f|
|
18
|
+
m = File.read(f).match(/type\s([a-z\d\:_]+)/i)
|
19
|
+
next if m =~ /type|alias/ # can't figure out the best way to filter type and alias out
|
20
|
+
m[1] if m && m[1] =~ /::/
|
21
|
+
end.uniq.compact
|
22
|
+
end
|
23
|
+
|
24
|
+
# @return [Array[String]] - a list of core data types
|
25
|
+
def core_datatypes
|
26
|
+
loaders.implementation_registry
|
27
|
+
.instance_variable_get(:'@implementations_per_type_name')
|
28
|
+
.keys.find_all { |t| t !~ /::/ }
|
29
|
+
end
|
30
|
+
|
31
|
+
# @return [Array[String]] - combined list of core data types and environment data types
|
32
|
+
def all_data_types
|
33
|
+
unless loaders.respond_to?(:implementation_registry)
|
34
|
+
Puppet.info("Data Types Not Available in Puppet: #{Puppet.version}")
|
35
|
+
return []
|
36
|
+
end
|
37
|
+
core_datatypes + environment_data_types
|
13
38
|
end
|
14
39
|
|
15
40
|
end
|
data/lib/puppet-debugger/cli.rb
CHANGED
@@ -71,7 +71,8 @@ module PuppetDebugger
|
|
71
71
|
scoped_vars = variables.map { |k, _v| scope.compiler.topscope.exist?(k) ? "$::#{k}" : "$#{k}" }
|
72
72
|
# append a () to functions so we know they are functions
|
73
73
|
funcs = function_map.keys.map { |k| "#{k.split('::').last}()" }
|
74
|
-
|
74
|
+
PuppetDebugger::InputResponders::Datatypes.instance.debugger = self
|
75
|
+
(scoped_vars + funcs + static_responder_list + PuppetDebugger::InputResponders::Datatypes.instance.all_data_types).uniq.sort
|
75
76
|
end
|
76
77
|
|
77
78
|
# looks up the type in the catalog by using the type and title
|
@@ -7,7 +7,7 @@ module PuppetDebugger
|
|
7
7
|
include Singleton
|
8
8
|
extend Forwardable
|
9
9
|
attr_accessor :debugger
|
10
|
-
def_delegators :debugger, :scope, :node, :environment,
|
10
|
+
def_delegators :debugger, :scope, :node, :environment, :loaders, :puppet_environment,
|
11
11
|
:add_hook, :handle_input, :delete_hook, :function_map
|
12
12
|
def_delegators :scope, :compiler, :catalog
|
13
13
|
def_delegators :node, :facts
|
@@ -8,32 +8,6 @@ module PuppetDebugger
|
|
8
8
|
Puppet::Pops::Loaders.new(environment)
|
9
9
|
end
|
10
10
|
|
11
|
-
# @return [Array[String]] - returns a list of all the custom data types found in all the modules in the environment
|
12
|
-
def environment_data_types
|
13
|
-
files = Dir.glob(puppet_environment.modulepath.map { |m| File.join(m, '**', 'types', '**', '*.pp') })
|
14
|
-
files.map do |f|
|
15
|
-
m = File.read(f).match(/type\s([a-z\d\:_]+)/i)
|
16
|
-
next if m =~ /type|alias/ # can't figure out the best way to filter type and alias out
|
17
|
-
m[1] if m && m[1] =~ /::/
|
18
|
-
end.uniq.compact
|
19
|
-
end
|
20
|
-
|
21
|
-
# @return [Array[String]] - a list of core data types
|
22
|
-
def core_datatypes
|
23
|
-
loaders.implementation_registry
|
24
|
-
.instance_variable_get(:'@implementations_per_type_name')
|
25
|
-
.keys.find_all { |t| t !~ /::/ }
|
26
|
-
end
|
27
|
-
|
28
|
-
# @return [Array[String]] - combined list of core data types and environment data types
|
29
|
-
def all_data_types
|
30
|
-
unless loaders.respond_to?(:implementation_registry)
|
31
|
-
Puppet.info("Data Types Not Available in Puppet: #{Puppet.version}")
|
32
|
-
return []
|
33
|
-
end
|
34
|
-
core_datatypes + environment_data_types
|
35
|
-
end
|
36
|
-
|
37
11
|
def loaders
|
38
12
|
@loaders ||= create_loader(puppet_environment)
|
39
13
|
end
|
data/lib/version.rb
CHANGED
data/puppet-debugger.gemspec
CHANGED
@@ -34,7 +34,7 @@ Gem::Specification.new do |s|
|
|
34
34
|
s.summary = "A repl based debugger for the puppet language"
|
35
35
|
s.add_runtime_dependency(%q<pluginator>, ["~> 1.5.0"])
|
36
36
|
s.add_runtime_dependency(%q<puppet>, [">= 3.8"])
|
37
|
-
s.add_runtime_dependency(%q<facterdb>, ["~> 0.
|
37
|
+
s.add_runtime_dependency(%q<facterdb>, ["~> 0.4.0"])
|
38
38
|
s.add_runtime_dependency(%q<awesome_print>, ["~> 1.7"])
|
39
39
|
s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
|
40
40
|
s.add_development_dependency(%q<rspec>, ["~> 3.6"])
|
@@ -14,4 +14,12 @@ describe :datatypes do
|
|
14
14
|
expect(output).to match(/.*Array.*/)
|
15
15
|
end
|
16
16
|
end
|
17
|
+
|
18
|
+
it 'returns core datatypes' do
|
19
|
+
expect(plugin.all_data_types.count).to be >= 30 if supports_datatypes?
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'returns environment datatypes' do
|
23
|
+
expect(plugin.environment_data_types.count).to be >= 0
|
24
|
+
end
|
17
25
|
end
|
@@ -24,4 +24,15 @@ describe :vars do
|
|
24
24
|
debugger.handle_input("$var1 = 'value1'")
|
25
25
|
expect(plugin.run(args)).to match(/value1/)
|
26
26
|
end
|
27
|
+
|
28
|
+
describe 'resource' do
|
29
|
+
let(:input) do
|
30
|
+
"$service_require = Package['httpd']"
|
31
|
+
end
|
32
|
+
it 'can process a resource' do
|
33
|
+
debugger_output = /Facts/
|
34
|
+
debugger.handle_input(input)
|
35
|
+
expect(plugin.run(args)).to match(debugger_output)
|
36
|
+
end
|
37
|
+
end
|
27
38
|
end
|
@@ -80,6 +80,16 @@ describe 'PuppetDebugger' do
|
|
80
80
|
end
|
81
81
|
end
|
82
82
|
|
83
|
+
describe 'key_words' do
|
84
|
+
it do
|
85
|
+
expect(debugger.key_words.count).to be >= 30 if supports_datatypes?
|
86
|
+
end
|
87
|
+
|
88
|
+
it do
|
89
|
+
expect(debugger.key_words.count).to be >= 0 unless supports_datatypes?
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
83
93
|
describe 'native functions', native_functions: true do
|
84
94
|
let(:func) do
|
85
95
|
<<-EOF
|
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.9.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: 2017-
|
11
|
+
date: 2017-10-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pluginator
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 0.
|
47
|
+
version: 0.4.0
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0.
|
54
|
+
version: 0.4.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: awesome_print
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|