puppet-debugger 0.12.1 → 0.12.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitlab-ci.yml +8 -33
- data/CHANGELOG.md +4 -0
- data/lib/plugins/puppet-debugger/input_responders/functions.rb +30 -33
- data/lib/puppet-debugger/version.rb +1 -1
- data/spec/input_responders/functions_spec.rb +34 -26
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1bbafde4d18168b16c4cfb22306b2d793e8e10b6
|
4
|
+
data.tar.gz: b3f50cb0d41f2286dfd71dd7837781a04ea693ff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8b6b9337d3d11a98c03a4ead272bd6f9918d7d5a2a7d8b16b9f82ed337c7eb33eb4366646865e565f7aa8bf7ed9c66f5e30884a70a3aa3313cf30fcfd3048b4d
|
7
|
+
data.tar.gz: 4c6fafdbfafd13f1d0260c59bc3def51265969c22fee32a651fb7a6fcd2a0d25bd42fe55fff87db886c43db1cdaf8421f8105ffc9a9e52a67e18ba3621992c4b
|
data/.gitlab-ci.yml
CHANGED
@@ -44,7 +44,7 @@ bump_and_tag:
|
|
44
44
|
only:
|
45
45
|
- master@puppet-debugger/puppet-debugger
|
46
46
|
script:
|
47
|
-
- gem install release_me
|
47
|
+
- gem install release_me
|
48
48
|
- bump_and_tag
|
49
49
|
|
50
50
|
#web_trigger_production:
|
@@ -61,10 +61,10 @@ bump_and_tag:
|
|
61
61
|
.ruby_22: &ruby22
|
62
62
|
image: ruby:2.2
|
63
63
|
script:
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
64
|
+
- gem install bundler -v 1.17.3 > /dev/null
|
65
|
+
- bundle install --without development validate
|
66
|
+
- bundle exec puppet module install puppetlabs-stdlib
|
67
|
+
- bundle exec rake spec
|
68
68
|
|
69
69
|
.ruby_23: &ruby23
|
70
70
|
image: ruby:2.3
|
@@ -75,7 +75,6 @@ bump_and_tag:
|
|
75
75
|
.ruby_25: &ruby25
|
76
76
|
image: ruby:2.5
|
77
77
|
|
78
|
-
|
79
78
|
.ruby_26: &ruby26
|
80
79
|
image: ruby:2.6
|
81
80
|
|
@@ -91,33 +90,9 @@ gem_production:
|
|
91
90
|
only:
|
92
91
|
- tags
|
93
92
|
|
94
|
-
puppet_43_ruby22:
|
95
|
-
variables:
|
96
|
-
PUPPET_GEM_VERSION: "~> 4.3.0"
|
97
|
-
<<: *puppet_job_def
|
98
|
-
<<: *ruby22
|
99
|
-
|
100
|
-
puppet_44_ruby22:
|
101
|
-
variables:
|
102
|
-
PUPPET_GEM_VERSION: "~> 4.4.0"
|
103
|
-
<<: *puppet_job_def
|
104
|
-
<<: *ruby22
|
105
|
-
|
106
|
-
puppet_46_ruby22:
|
107
|
-
variables:
|
108
|
-
PUPPET_GEM_VERSION: "~> 4.6.0"
|
109
|
-
<<: *puppet_job_def
|
110
|
-
<<: *ruby22
|
111
|
-
|
112
|
-
puppet_47_ruby22:
|
113
|
-
variables:
|
114
|
-
PUPPET_GEM_VERSION: "~> 4.7.0"
|
115
|
-
<<: *puppet_job_def
|
116
|
-
<<: *ruby22
|
117
|
-
|
118
93
|
puppet_410_ruby24:
|
119
94
|
variables:
|
120
|
-
PUPPET_GEM_VERSION: "~> 4.10
|
95
|
+
PUPPET_GEM_VERSION: "~> 4.10"
|
121
96
|
<<: *puppet_job_def
|
122
97
|
<<: *ruby24
|
123
98
|
|
@@ -127,13 +102,13 @@ puppet_55_ruby24:
|
|
127
102
|
<<: *puppet_job_def
|
128
103
|
<<: *ruby24
|
129
104
|
|
130
|
-
|
105
|
+
puppet_63_ruby25:
|
131
106
|
variables:
|
132
107
|
PUPPET_GEM_VERSION: "~> 6.0"
|
133
108
|
<<: *puppet_job_def
|
134
109
|
<<: *ruby25
|
135
110
|
|
136
|
-
|
111
|
+
puppet_64_ruby26:
|
137
112
|
variables:
|
138
113
|
PUPPET_GEM_VERSION: "~> 6.4"
|
139
114
|
<<: *puppet_job_def
|
data/CHANGELOG.md
CHANGED
@@ -1,30 +1,30 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "puppet-debugger/input_responder_plugin"
|
2
|
+
require "table_print"
|
3
3
|
|
4
4
|
module PuppetDebugger
|
5
5
|
module InputResponders
|
6
6
|
class Functions < InputResponderPlugin
|
7
7
|
COMMAND_WORDS = %w(functions)
|
8
|
-
SUMMARY =
|
8
|
+
SUMMARY = "List all the functions available in the environment."
|
9
9
|
COMMAND_GROUP = :environment
|
10
10
|
FUNC_NATIVE_NAME_REGEX = %r{\Afunction\s([\w\:]+)}
|
11
11
|
FUNC_V4_NAME_REGEX = %r{Puppet\:\:Functions.create_function\s?\(?\:?\'?([\w\:]+)}
|
12
12
|
|
13
13
|
def run(args = [])
|
14
|
-
filter = args.first ||
|
14
|
+
filter = args.first || ""
|
15
15
|
TablePrint::Printer.table_print(sorted_list(filter), [:full_name, :mod_name])
|
16
16
|
end
|
17
17
|
|
18
|
-
def sorted_list(filter =
|
18
|
+
def sorted_list(filter = "")
|
19
19
|
search = /#{Regexp.escape(filter)}/
|
20
|
-
function_map.values.find_all do |
|
20
|
+
function_map.values.find_all do |v|
|
21
21
|
"#{v[:mod_name]}_#{v[:full_name]}" =~ search
|
22
|
-
end.sort {|a,b| a[:full_name] <=> b[:full_name]}
|
22
|
+
end.sort { |a, b| a[:full_name] <=> b[:full_name] }
|
23
23
|
end
|
24
24
|
|
25
25
|
# append a () to functions so we know they are functions
|
26
26
|
def func_list
|
27
|
-
# ideally we should get a list of function names via the puppet loader
|
27
|
+
# ideally we should get a list of function names via the puppet loader
|
28
28
|
function_map.map { |name, metadata| "#{metadata[:full_name]}()" }
|
29
29
|
end
|
30
30
|
|
@@ -39,7 +39,6 @@ module PuppetDebugger
|
|
39
39
|
functions
|
40
40
|
end
|
41
41
|
|
42
|
-
|
43
42
|
def lib_dirs(module_dirs = modules_paths)
|
44
43
|
dirs = module_dirs.map do |mod_dir|
|
45
44
|
Dir["#{mod_dir}/*/lib"].entries
|
@@ -47,38 +46,38 @@ module PuppetDebugger
|
|
47
46
|
dirs + [puppet_debugger_lib_dir]
|
48
47
|
end
|
49
48
|
|
50
|
-
|
51
49
|
# @return [Array] - returns a array of the parentname and function name
|
52
50
|
def function_obj(file)
|
53
51
|
namespace = nil
|
54
52
|
name = nil
|
55
53
|
if file =~ /\.pp/
|
56
|
-
File.readlines(file, :encoding =>
|
54
|
+
File.readlines(file, :encoding => "UTF-8").find do |line|
|
57
55
|
# TODO: not getting namespace for functio
|
58
|
-
if line.match(FUNC_NATIVE_NAME_REGEX)
|
59
|
-
namespace, name = $1.split(
|
56
|
+
if line.match(FUNC_NATIVE_NAME_REGEX)
|
57
|
+
namespace, name = $1.split("::", 2)
|
60
58
|
name = namespace if name.nil?
|
61
|
-
namespace =
|
59
|
+
namespace = "" if namespace == name
|
62
60
|
end
|
63
61
|
end
|
64
|
-
elsif file.include?(
|
65
|
-
File.readlines(file, :encoding =>
|
66
|
-
if line.match(FUNC_V4_NAME_REGEX)
|
67
|
-
namespace, name = $1.split(
|
62
|
+
elsif file.include?("lib/puppet/functions")
|
63
|
+
File.readlines(file, :encoding => "UTF-8").find do |line|
|
64
|
+
if line.match(FUNC_V4_NAME_REGEX)
|
65
|
+
namespace, name = $1.split("::", 2)
|
68
66
|
name = namespace if name.nil?
|
69
|
-
namespace =
|
67
|
+
namespace = "" if namespace == name
|
70
68
|
end
|
71
69
|
end
|
72
70
|
end
|
73
|
-
name ||= File.basename(file, File.extname(file))
|
71
|
+
name ||= File.basename(file, File.extname(file))
|
74
72
|
match = file.match('\/(?<mod>[\w\-\.]+)\/(lib|functions|manifests)')
|
75
|
-
summary_match = File.read(file, :encoding =>
|
73
|
+
summary_match = File.read(file, :encoding => "UTF-8").match(/@summary\s(.*)/)
|
76
74
|
summary = summary_match[1] if summary_match
|
77
|
-
|
78
|
-
|
79
|
-
|
75
|
+
# fetch the puppet version if this is a function from puppet gem
|
76
|
+
captures = file.match(/(puppet-[\d\.]+)/)
|
77
|
+
file_namespace = captures[1] if captures
|
78
|
+
mod_name = match.nil? ? file_namespace : match[:mod]
|
80
79
|
full_name = namespace.nil? || namespace.empty? ? name : name.prepend("#{namespace}::")
|
81
|
-
{namespace: namespace, summary: summary, mod_name: mod_name, name: name, full_name: full_name, file: file}
|
80
|
+
{ namespace: namespace, summary: summary, mod_name: mod_name, name: name, full_name: full_name, file: file }
|
82
81
|
end
|
83
82
|
|
84
83
|
private
|
@@ -96,19 +95,17 @@ module PuppetDebugger
|
|
96
95
|
# in the future we may want to utilize the puppet loaders to find these things
|
97
96
|
def function_files
|
98
97
|
search_dirs = lib_dirs.map do |lib_dir|
|
99
|
-
[File.join(lib_dir,
|
100
|
-
File.join(lib_dir,
|
101
|
-
File.join(File.dirname(lib_dir),
|
102
|
-
File.join(lib_dir,
|
98
|
+
[File.join(lib_dir, "puppet", "functions", "**", "*.rb"),
|
99
|
+
File.join(lib_dir, "functions", "**", "*.rb"),
|
100
|
+
File.join(File.dirname(lib_dir), "functions", "**", "*.pp"),
|
101
|
+
File.join(lib_dir, "puppet", "parser", "functions", "*.rb")]
|
103
102
|
end
|
104
103
|
|
105
104
|
# add puppet lib directories
|
106
|
-
search_dirs << [File.join(puppet_lib_dir,
|
107
|
-
File.join(puppet_lib_dir,
|
105
|
+
search_dirs << [File.join(puppet_lib_dir, "puppet", "functions", "**", "*.rb"),
|
106
|
+
File.join(puppet_lib_dir, "puppet", "parser", "functions", "*.rb")]
|
108
107
|
Dir.glob(search_dirs.flatten)
|
109
108
|
end
|
110
|
-
|
111
|
-
|
112
109
|
end
|
113
110
|
end
|
114
111
|
end
|
@@ -1,65 +1,73 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
1
|
+
require "spec_helper"
|
2
|
+
require "puppet-debugger"
|
3
|
+
require "puppet-debugger/plugin_test_helper"
|
4
4
|
|
5
5
|
describe :functions do
|
6
|
-
include_examples
|
6
|
+
include_examples "plugin_tests"
|
7
7
|
|
8
8
|
let(:input) do
|
9
9
|
"md5('hello')"
|
10
10
|
end
|
11
11
|
|
12
12
|
let(:mod_dir) do
|
13
|
-
File.join(fixtures_dir,
|
13
|
+
File.join(fixtures_dir, "modules", "extlib")
|
14
14
|
end
|
15
15
|
|
16
|
-
it
|
16
|
+
it "runs" do
|
17
17
|
expect(plugin.run).to be_a String
|
18
18
|
end
|
19
19
|
|
20
|
-
it
|
20
|
+
it "returns functions" do
|
21
21
|
expect(plugin.function_map).to be_a Hash
|
22
22
|
end
|
23
23
|
|
24
|
-
it
|
24
|
+
it "sorted_list" do
|
25
25
|
expect(plugin.sorted_list).to be_a Array
|
26
26
|
expect(plugin.sorted_list.first).to be_a Hash
|
27
27
|
end
|
28
28
|
|
29
|
-
it
|
29
|
+
it "returns function names" do
|
30
30
|
expect(plugin.func_list).to be_a Array
|
31
|
-
expect(plugin.func_list.find {|m| m =~ /md5/ }).to eq(
|
31
|
+
expect(plugin.func_list.find { |m| m =~ /md5/ }).to eq("md5()")
|
32
32
|
end
|
33
33
|
|
34
|
-
it
|
34
|
+
it "execute md5" do
|
35
35
|
debugger_output = /5d41402abc4b2a76b9719d911017c592/
|
36
36
|
debugger.handle_input("md5('hello')")
|
37
37
|
expect(output.string).to match(debugger_output)
|
38
38
|
end
|
39
39
|
|
40
|
-
it
|
40
|
+
it "execute swapcase" do
|
41
41
|
debugger_output = /HELLO/
|
42
42
|
debugger.handle_input("swapcase('hello')")
|
43
43
|
expect(output.string).to match(debugger_output)
|
44
44
|
end
|
45
45
|
|
46
|
-
it
|
47
|
-
expect(plugin.function_obj(File.join(mod_dir,
|
48
|
-
{:file=>File.join(mod_dir,
|
49
|
-
|
50
|
-
|
51
|
-
|
46
|
+
it "#function_obj with native function" do
|
47
|
+
expect(plugin.function_obj(File.join(mod_dir, "functions", "dir_split.pp"))).to eq(
|
48
|
+
{ :file => File.join(mod_dir, "functions", "dir_split.pp"), :mod_name => "extlib",
|
49
|
+
:full_name => "extlib::dir_split", :name => "extlib::dir_split", :namespace => "extlib",
|
50
|
+
:summary => "Splits the given directory or directories into individual paths." }
|
51
|
+
)
|
52
52
|
end
|
53
53
|
|
54
|
-
it
|
55
|
-
expect(plugin.function_obj(File.join(mod_dir,
|
56
|
-
|
57
|
-
:full_name=>"echo", :name=>"echo", :namespace=>"", :summary => "DEPRECATED. Use the namespaced function [`extlib::echo`](#extlibecho) instead."})
|
54
|
+
it "#function_obj ruby v4 without namespace" do
|
55
|
+
expect(plugin.function_obj(File.join(mod_dir, "lib", "puppet", "functions", "echo.rb"))).to eq({ :file => File.join(mod_dir, "lib", "puppet", "functions", "echo.rb"), :mod_name => "extlib",
|
56
|
+
:full_name => "echo", :name => "echo", :namespace => "", :summary => "DEPRECATED. Use the namespaced function [`extlib::echo`](#extlibecho) instead." })
|
58
57
|
end
|
59
58
|
|
60
|
-
it
|
61
|
-
expect(plugin.function_obj(File.join(mod_dir,
|
62
|
-
|
63
|
-
|
59
|
+
it "#function_obj ruby v4 and namespace" do
|
60
|
+
expect(plugin.function_obj(File.join(mod_dir, "lib", "puppet", "functions", "extlib", "echo.rb"))).to eq({ :file => File.join(mod_dir, "lib", "puppet", "functions", "extlib", "echo.rb"), :mod_name => "extlib",
|
61
|
+
:full_name => "extlib::echo", :name => "extlib::echo", :namespace => "extlib", :summary => nil })
|
62
|
+
end
|
63
|
+
|
64
|
+
it "#function_obj has puppet namespace" do
|
65
|
+
file, _ = Puppet::Functions.method(:create_function).source_location
|
66
|
+
dir = File.dirname(file)
|
67
|
+
f_obj = plugin.function_obj(File.join(dir, "functions", "include.rb"))
|
68
|
+
expect(f_obj[:mod_name]).to match(/puppet-.*/)
|
69
|
+
expect(f_obj[:name]).to eq("include")
|
70
|
+
expect(f_obj[:full_name]).to eq("include")
|
71
|
+
expect(f_obj[:summary]).to be_nil
|
64
72
|
end
|
65
73
|
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.12.
|
4
|
+
version: 0.12.2
|
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-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: table_print
|