puppet-repl 0.2.3 → 0.3.0
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/.gitignore +53 -0
- data/.gitlab-ci.yml +28 -32
- data/.rspec +2 -1
- data/CHANGELOG.md +3 -0
- data/Gemfile +3 -3
- data/Gemfile.lock +4 -46
- data/README.md +5 -3
- data/Rakefile +4 -24
- data/lib/puppet-repl/cli.rb +5 -7
- data/lib/puppet-repl/support/input_responders.rb +1 -0
- data/lib/puppet-repl/support.rb +42 -2
- data/lib/version.rb +1 -1
- data/puppet-repl.gemspec +18 -76
- data/run_container_test.sh +12 -0
- data/spec/fixtures/invalid_node_obj.yaml +2 -2
- data/spec/fixtures/node_obj.yaml +45 -62
- data/spec/prepl_spec.rb +9 -9
- data/spec/puppet-repl_spec.rb +122 -178
- data/spec/remote_node_spec.rb +170 -0
- data/spec/spec_helper.rb +24 -16
- data/test_matrix.rb +42 -0
- metadata +9 -13
- data/VERSION +0 -1
- data/resources/classes.png +0 -0
- data/resources/classification.png +0 -0
- data/resources/command_line_node.png +0 -0
- data/resources/functions.png +0 -0
- data/resources/hiera.png +0 -0
- data/resources/set_node.png +0 -0
- data/resources/tab_complete.png +0 -0
- data/resources/variables.png +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8726c62a0923768b64cf07c7a4a020d331a6dbb4
|
4
|
+
data.tar.gz: 483b212a7d21da6bc76264b2c4efae120b72ba74
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ee46f50573a316eb2f92a5bd4ff16af968ae691b3d39d1a5f26957d1a71c1f32d22a169df3a8f0511fd8e5a724290c6179484700d5b750d6b71c8e559eb11450
|
7
|
+
data.tar.gz: 61f17a2d77901d5321a996c0fb4bbb0824fd088473ca0e733990d05b0036626c4c0c30168d3becda2384f31812b82d2364bd36a92a4cea2c9a2c35b4460fa6ad
|
data/.gitignore
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
# rcov generated
|
2
|
+
local_test_results
|
3
|
+
bundle
|
4
|
+
bundler
|
5
|
+
vendor
|
6
|
+
coverage
|
7
|
+
coverage.data
|
8
|
+
|
9
|
+
# rdoc generated
|
10
|
+
rdoc
|
11
|
+
|
12
|
+
# yard generated
|
13
|
+
doc
|
14
|
+
.yardoc
|
15
|
+
|
16
|
+
# bundler
|
17
|
+
.bundle
|
18
|
+
|
19
|
+
# jeweler generated
|
20
|
+
pkg
|
21
|
+
|
22
|
+
# Have editor/IDE/OS specific files you need to ignore? Consider using a global gitignore:
|
23
|
+
#
|
24
|
+
# * Create a file at ~/.gitignore
|
25
|
+
# * Include files you want ignored
|
26
|
+
# * Run: git config --global core.excludesfile ~/.gitignore
|
27
|
+
#
|
28
|
+
# After doing this, these files will be ignored in all your git projects,
|
29
|
+
# saving you from having to 'pollute' every project you touch with them
|
30
|
+
#
|
31
|
+
# Not sure what to needs to be ignored for particular editors/OSes? Here's some ideas to get you started. (Remember, remove the leading # of the line)
|
32
|
+
#
|
33
|
+
# For MacOS:
|
34
|
+
#
|
35
|
+
#.DS_Store
|
36
|
+
|
37
|
+
# For TextMate
|
38
|
+
#*.tmproj
|
39
|
+
#tmtags
|
40
|
+
|
41
|
+
# For emacs:
|
42
|
+
#*~
|
43
|
+
#\#*
|
44
|
+
#.\#*
|
45
|
+
|
46
|
+
# For vim:
|
47
|
+
#*.swp
|
48
|
+
|
49
|
+
# For redcar:
|
50
|
+
#.redcar
|
51
|
+
|
52
|
+
# For rubinius:
|
53
|
+
#*.rbc
|
data/.gitlab-ci.yml
CHANGED
@@ -3,17 +3,31 @@ stages:
|
|
3
3
|
- deploy
|
4
4
|
- web_deploy
|
5
5
|
|
6
|
-
variables:
|
7
|
-
HEROKU_STAGING_APP: murmuring-plateau-62715
|
8
|
-
HEROKU_PROD_APP: still-tor-57873
|
9
|
-
|
10
6
|
.puppet_def: &puppet_job_def
|
11
7
|
stage: test
|
12
8
|
script:
|
9
|
+
- gem update --system > /dev/null
|
10
|
+
- gem install bundler > /dev/null
|
13
11
|
- bundle install --without development
|
14
12
|
- bundle exec puppet module install puppetlabs-stdlib
|
15
13
|
- bundle exec rake spec
|
16
14
|
|
15
|
+
web_trigger_staging:
|
16
|
+
type: web_deploy
|
17
|
+
variables:
|
18
|
+
REF: staging
|
19
|
+
only:
|
20
|
+
- tags
|
21
|
+
script:
|
22
|
+
- "curl -X POST -F token=$PREPL_BUILD_TRIGGER_TOKEN -F ref=$REF https://gitlab.com/api/v3/projects/1146764/trigger/builds"
|
23
|
+
|
24
|
+
web_trigger_production:
|
25
|
+
type: web_deploy
|
26
|
+
variables:
|
27
|
+
REF: production
|
28
|
+
script:
|
29
|
+
- "curl -X POST -F token=$PREPL_BUILD_TRIGGER_TOKEN -F ref=$REF https://gitlab.com/api/v3/projects/1146764/trigger/builds"
|
30
|
+
|
17
31
|
.ruby_193: &ruby193
|
18
32
|
image: ruby:1.9.3
|
19
33
|
|
@@ -39,80 +53,62 @@ gem_production:
|
|
39
53
|
only:
|
40
54
|
- tags
|
41
55
|
|
42
|
-
# web_staging:
|
43
|
-
# stage: web_deploy
|
44
|
-
# before_script:
|
45
|
-
# - gem install dpl
|
46
|
-
# script:
|
47
|
-
# - dpl --provider=heroku --strategy=git --app=$HEROKU_STAGING_APP --api-key=$HEROKU_API_KEY
|
48
|
-
# only:
|
49
|
-
# - master
|
50
|
-
#
|
51
|
-
# web_production:
|
52
|
-
# stage: web_deploy
|
53
|
-
# before_script:
|
54
|
-
# - gem install dpl
|
55
|
-
# script:
|
56
|
-
# - dpl --provider=heroku --strategy=git --app=$HEROKU_PROD_APP --api-key=$HEROKU_API_KEY
|
57
|
-
# only:
|
58
|
-
# - tags
|
59
|
-
|
60
56
|
puppet_38_ruby193:
|
61
57
|
variables:
|
62
|
-
PUPPET_GEM_VERSION:
|
58
|
+
PUPPET_GEM_VERSION: "~> 3.8"
|
63
59
|
<<: *puppet_job_def
|
64
60
|
<<: *ruby193
|
65
61
|
|
66
62
|
puppet_38_ruby20:
|
67
63
|
variables:
|
68
|
-
PUPPET_GEM_VERSION:
|
64
|
+
PUPPET_GEM_VERSION: "~> 3.8"
|
69
65
|
<<: *puppet_job_def
|
70
66
|
<<: *ruby20
|
71
67
|
|
72
68
|
puppet_38_ruby21:
|
73
69
|
variables:
|
74
|
-
PUPPET_GEM_VERSION:
|
70
|
+
PUPPET_GEM_VERSION: "~> 3.8"
|
75
71
|
<<: *puppet_job_def
|
76
72
|
<<: *ruby21
|
77
73
|
|
78
74
|
puppet_43_ruby20:
|
79
75
|
variables:
|
80
|
-
PUPPET_GEM_VERSION:
|
76
|
+
PUPPET_GEM_VERSION: "~> 4.3"
|
81
77
|
<<: *puppet_job_def
|
82
78
|
<<: *ruby20
|
83
79
|
|
84
80
|
puppet_43_ruby21:
|
85
81
|
variables:
|
86
|
-
PUPPET_GEM_VERSION:
|
82
|
+
PUPPET_GEM_VERSION: "~> 4.3"
|
87
83
|
<<: *puppet_job_def
|
88
84
|
<<: *ruby21
|
89
85
|
|
90
86
|
puppet_43_ruby22:
|
91
87
|
variables:
|
92
|
-
PUPPET_GEM_VERSION:
|
88
|
+
PUPPET_GEM_VERSION: "~> 4.3"
|
93
89
|
<<: *puppet_job_def
|
94
90
|
<<: *ruby22
|
95
91
|
|
96
92
|
puppet_44_ruby21:
|
97
93
|
variables:
|
98
|
-
PUPPET_GEM_VERSION:
|
94
|
+
PUPPET_GEM_VERSION: "~> 4.4"
|
99
95
|
<<: *puppet_job_def
|
100
96
|
<<: *ruby21
|
101
97
|
|
102
98
|
puppet_44_ruby22:
|
103
99
|
variables:
|
104
|
-
PUPPET_GEM_VERSION:
|
100
|
+
PUPPET_GEM_VERSION: "~> 4.4"
|
105
101
|
<<: *puppet_job_def
|
106
102
|
<<: *ruby22
|
107
103
|
|
108
104
|
puppet_45_ruby21:
|
109
105
|
variables:
|
110
|
-
PUPPET_GEM_VERSION:
|
106
|
+
PUPPET_GEM_VERSION: "~> 4.5"
|
111
107
|
<<: *puppet_job_def
|
112
108
|
<<: *ruby21
|
113
109
|
|
114
110
|
puppet_45_ruby22:
|
115
111
|
variables:
|
116
|
-
PUPPET_GEM_VERSION:
|
112
|
+
PUPPET_GEM_VERSION: "~> 4.5"
|
117
113
|
<<: *puppet_job_def
|
118
114
|
<<: *ruby22
|
data/.rspec
CHANGED
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
@@ -2,15 +2,15 @@ source "http://rubygems.org"
|
|
2
2
|
gem 'puppet', ENV['PUPPET_GEM_VERSION'] || ">= 3.8"
|
3
3
|
gem 'facterdb', "~> 0.3"
|
4
4
|
gem 'awesome_print', "~> 1.6"
|
5
|
+
|
5
6
|
group :test do
|
7
|
+
gem "rdoc", "~> 3.12"
|
6
8
|
gem "rspec"
|
7
9
|
gem "bundler"
|
8
|
-
gem "jeweler", "~> 2.0.1"
|
9
10
|
gem "simplecov", ">= 0"
|
10
11
|
gem 'rake'
|
11
|
-
gem 'pry'
|
12
12
|
end
|
13
13
|
|
14
14
|
group :development do
|
15
|
-
gem
|
15
|
+
gem 'pry'
|
16
16
|
end
|
data/Gemfile.lock
CHANGED
@@ -2,12 +2,8 @@ GEM
|
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
4
|
CFPropertyList (2.2.8)
|
5
|
-
addressable (2.4.0)
|
6
5
|
awesome_print (1.6.1)
|
7
|
-
builder (3.2.2)
|
8
6
|
coderay (1.1.1)
|
9
|
-
descendants_tracker (0.0.4)
|
10
|
-
thread_safe (~> 0.3, >= 0.3.1)
|
11
7
|
diff-lcs (1.2.5)
|
12
8
|
docile (1.1.5)
|
13
9
|
facter (2.4.6)
|
@@ -15,57 +11,21 @@ GEM
|
|
15
11
|
facterdb (0.3.5)
|
16
12
|
facter
|
17
13
|
jgrep
|
18
|
-
|
19
|
-
multipart-post (>= 1.2, < 3)
|
20
|
-
git (1.3.0)
|
21
|
-
github_api (0.13.1)
|
22
|
-
addressable (~> 2.4.0)
|
23
|
-
descendants_tracker (~> 0.0.4)
|
24
|
-
faraday (~> 0.8, < 0.10)
|
25
|
-
hashie (>= 3.4)
|
26
|
-
multi_json (>= 1.7.5, < 2.0)
|
27
|
-
oauth2
|
28
|
-
hashie (3.4.4)
|
29
|
-
hiera (3.1.2)
|
14
|
+
hiera (3.2.0)
|
30
15
|
json_pure
|
31
|
-
highline (1.7.8)
|
32
|
-
jeweler (2.0.1)
|
33
|
-
builder
|
34
|
-
bundler (>= 1.0)
|
35
|
-
git (>= 1.2.5)
|
36
|
-
github_api
|
37
|
-
highline (>= 1.6.15)
|
38
|
-
nokogiri (>= 1.5.10)
|
39
|
-
rake
|
40
|
-
rdoc
|
41
16
|
jgrep (1.4.1)
|
42
17
|
json
|
43
18
|
json (1.8.3)
|
44
|
-
json_pure (
|
45
|
-
jwt (1.5.1)
|
19
|
+
json_pure (2.0.1)
|
46
20
|
method_source (0.8.2)
|
47
|
-
mini_portile2 (2.0.0)
|
48
|
-
multi_json (1.12.0)
|
49
|
-
multi_xml (0.5.5)
|
50
|
-
multipart-post (2.0.0)
|
51
|
-
nokogiri (1.6.7.2)
|
52
|
-
mini_portile2 (~> 2.0.0.rc2)
|
53
|
-
oauth2 (1.1.0)
|
54
|
-
faraday (>= 0.8, < 0.10)
|
55
|
-
jwt (~> 1.0, < 1.5.2)
|
56
|
-
multi_json (~> 1.3)
|
57
|
-
multi_xml (~> 0.5)
|
58
|
-
rack (>= 1.2, < 3)
|
59
21
|
pry (0.10.3)
|
60
22
|
coderay (~> 1.1.0)
|
61
23
|
method_source (~> 0.8.1)
|
62
24
|
slop (~> 3.4)
|
63
|
-
puppet (4.
|
64
|
-
CFPropertyList (~> 2.2.6)
|
25
|
+
puppet (4.5.2)
|
65
26
|
facter (> 2.0, < 4)
|
66
27
|
hiera (>= 2.0, < 4)
|
67
28
|
json_pure
|
68
|
-
rack (1.6.4)
|
69
29
|
rake (11.1.2)
|
70
30
|
rdoc (3.12.2)
|
71
31
|
json (~> 1.4)
|
@@ -88,7 +48,6 @@ GEM
|
|
88
48
|
simplecov-html (~> 0.10.0)
|
89
49
|
simplecov-html (0.10.0)
|
90
50
|
slop (3.6.0)
|
91
|
-
thread_safe (0.3.5)
|
92
51
|
|
93
52
|
PLATFORMS
|
94
53
|
ruby
|
@@ -97,7 +56,6 @@ DEPENDENCIES
|
|
97
56
|
awesome_print (~> 1.6)
|
98
57
|
bundler
|
99
58
|
facterdb (~> 0.3)
|
100
|
-
jeweler (~> 2.0.1)
|
101
59
|
pry
|
102
60
|
puppet (>= 3.8)
|
103
61
|
rake
|
@@ -106,4 +64,4 @@ DEPENDENCIES
|
|
106
64
|
simplecov
|
107
65
|
|
108
66
|
BUNDLED WITH
|
109
|
-
1.12.
|
67
|
+
1.12.5
|
data/README.md
CHANGED
@@ -31,7 +31,7 @@
|
|
31
31
|
[](https://badge.fury.io/rb/puppet-repl)
|
32
32
|
# puppet-repl
|
33
33
|
|
34
|
-
A interactive command line tool for evaluating the puppet language.
|
34
|
+
A interactive command line tool for evaluating and debugging the puppet language.
|
35
35
|
|
36
36
|
## Compatibility
|
37
37
|
Requires Puppet 3.8+ and only uses the future parser.
|
@@ -47,7 +47,7 @@ to install on your production puppet master. Please do not install because of th
|
|
47
47
|
puppet-repl will load all functions from your basemodulepath and environmentpath.
|
48
48
|
|
49
49
|
This means if you run `puppet module install puppetlabs-stdlib` and they will be available
|
50
|
-
in the repl.
|
50
|
+
in the repl.
|
51
51
|
|
52
52
|
## Interactive demo
|
53
53
|
I have put together a repo with a few setup instructions that will assist you in setting up a "mock" environment
|
@@ -221,6 +221,8 @@ This is also extremely useful to check classification rules and variables by you
|
|
221
221
|
The puppet-repl uses readline internally. So any variable or function is also available for auto completion.
|
222
222
|
Press the tab key to engage the auto complete functionality.
|
223
223
|
|
224
|
+
Currently native functions are not available in auto complete. See #24
|
225
|
+
|
224
226
|
## Playback support
|
225
227
|
Puppet-repl now supports playing back files or urls and loading the content into the repl session. This means if you want to start a repl session from an existing file or url you can play the content back in the repl.
|
226
228
|
You can also playback a file that contains puppet code and repl commands.
|
@@ -237,7 +239,7 @@ If using the [web based repl](https://www.puppet-repl.com) you can playback a sh
|
|
237
239
|
which would start a repl session and then load the content from the url or parameter.
|
238
240
|
|
239
241
|
Example:
|
240
|
-
https://
|
242
|
+
https://murmuring-plateau-62715.herokuapp.com/play?url=https://gist.github.com/logicminds/64f0fe9f64339f18f097a9f42acd6276
|
241
243
|
|
242
244
|
or for single commands
|
243
245
|
|
data/Rakefile
CHANGED
@@ -2,8 +2,11 @@
|
|
2
2
|
|
3
3
|
require 'rubygems'
|
4
4
|
require 'bundler'
|
5
|
+
require "bundler/gem_tasks"
|
6
|
+
require "rake/testtask"
|
7
|
+
|
5
8
|
begin
|
6
|
-
Bundler.setup(:default, :development)
|
9
|
+
Bundler.setup(:default, :development, :test)
|
7
10
|
rescue Bundler::BundlerError => e
|
8
11
|
$stderr.puts e.message
|
9
12
|
$stderr.puts "Run `bundle install` to install missing gems"
|
@@ -11,40 +14,17 @@ rescue Bundler::BundlerError => e
|
|
11
14
|
end
|
12
15
|
require 'rake'
|
13
16
|
|
14
|
-
require 'jeweler'
|
15
|
-
require_relative 'lib/version'
|
16
|
-
Jeweler::Tasks.new do |gem|
|
17
|
-
# gem is a Gem::Specification... see http://guides.rubygems.org/specification-reference/ for more options
|
18
|
-
gem.name = "puppet-repl"
|
19
|
-
gem.version = "#{PuppetRepl::VERSION}"
|
20
|
-
gem.homepage = "http://github.com/nwops/puppet-repl"
|
21
|
-
gem.license = "MIT"
|
22
|
-
gem.summary = %Q{A repl for the puppet language}
|
23
|
-
gem.description = %Q{A interactive command line tool for evaluating the puppet language}
|
24
|
-
gem.email = "corey@nwops.io"
|
25
|
-
gem.authors = ["Corey Osman"]
|
26
|
-
# dependencies defined in Gemfile
|
27
|
-
end
|
28
|
-
Jeweler::RubygemsDotOrgTasks.new
|
29
|
-
|
30
17
|
require 'rspec/core'
|
31
18
|
require 'rspec/core/rake_task'
|
32
19
|
RSpec::Core::RakeTask.new(:spec) do |spec|
|
33
20
|
spec.pattern = FileList['spec/**/*_spec.rb']
|
34
21
|
end
|
35
22
|
|
36
|
-
desc "Code coverage detail"
|
37
|
-
task :simplecov do
|
38
|
-
ENV['COVERAGE'] = "true"
|
39
|
-
Rake::Task['spec'].execute
|
40
|
-
end
|
41
|
-
|
42
23
|
task :default => :spec
|
43
24
|
|
44
25
|
require 'rdoc/task'
|
45
26
|
Rake::RDocTask.new do |rdoc|
|
46
27
|
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
47
|
-
|
48
28
|
rdoc.rdoc_dir = 'rdoc'
|
49
29
|
rdoc.title = "puppet-repl #{version}"
|
50
30
|
rdoc.rdoc_files.include('README*')
|
data/lib/puppet-repl/cli.rb
CHANGED
@@ -41,10 +41,6 @@ module PuppetRepl
|
|
41
41
|
(scoped_vars + funcs + static_responder_list).uniq.sort
|
42
42
|
end
|
43
43
|
|
44
|
-
def puppet_eval(input)
|
45
|
-
parser.evaluate_string(scope, input)
|
46
|
-
end
|
47
|
-
|
48
44
|
# looks up the type in the catalog by using the type and title
|
49
45
|
# and returns the resource in ral format
|
50
46
|
def to_resource_declaration(type)
|
@@ -95,6 +91,7 @@ module PuppetRepl
|
|
95
91
|
#
|
96
92
|
def handle_input(input)
|
97
93
|
raise ArgumentError unless input.instance_of?(String)
|
94
|
+
|
98
95
|
begin
|
99
96
|
output = ''
|
100
97
|
case input
|
@@ -134,7 +131,7 @@ module PuppetRepl
|
|
134
131
|
rescue PuppetRepl::Exception::FatalError => e
|
135
132
|
output = e.message.fatal
|
136
133
|
out_buffer.puts output
|
137
|
-
exit 1
|
134
|
+
exit 1 # this can sometimes causes tests to fail
|
138
135
|
rescue PuppetRepl::Exception::Error => e
|
139
136
|
output = e.message.fatal
|
140
137
|
end
|
@@ -204,10 +201,11 @@ Type "exit", "functions", "vars", "krt", "facts", "resources", "classes",
|
|
204
201
|
opt :play, "Url or file to load from", :required => false, :type => String
|
205
202
|
opt :run_once, "Evaluate and quit", :required => false, :default => false
|
206
203
|
opt :node_name, "Remote Node to grab facts from", :required => false, :type => String
|
204
|
+
opt :quiet, "Do not display banner", :required => false, :default => false
|
207
205
|
end
|
208
206
|
options = opts.merge(options)
|
209
|
-
puts print_repl_desc
|
210
|
-
repl_obj = new
|
207
|
+
puts print_repl_desc unless options[:quiet]
|
208
|
+
repl_obj = PuppetRepl::Cli.new
|
211
209
|
repl_obj.remote_node_name = opts[:node_name] if opts[:node_name]
|
212
210
|
repl_obj.initialize_from_scope(options[:scope])
|
213
211
|
if options[:play]
|
data/lib/puppet-repl/support.rb
CHANGED
@@ -100,12 +100,52 @@ module PuppetRepl
|
|
100
100
|
def do_initialize
|
101
101
|
begin
|
102
102
|
Puppet.initialize_settings
|
103
|
+
Puppet[:parser] = 'future' # this is required in order to work with puppet 3.8
|
103
104
|
Puppet[:trusted_node_data] = true
|
104
|
-
rescue
|
105
|
+
rescue ArgumentError => e
|
106
|
+
|
107
|
+
rescue Puppet::DevError => e
|
105
108
|
# do nothing otherwise calling init twice raises an error
|
106
109
|
end
|
107
110
|
end
|
108
111
|
|
112
|
+
# @param String - any valid puppet language code
|
113
|
+
# @return Hostclass - a puppet Program object which is considered the main class
|
114
|
+
def generate_ast(string = nil)
|
115
|
+
parse_result = parser.parse_string(string, '')
|
116
|
+
# the parse_result may be
|
117
|
+
# * empty / nil (no input)
|
118
|
+
# * a Model::Program
|
119
|
+
# * a Model::Expression
|
120
|
+
#
|
121
|
+
model = parse_result.nil? ? nil : parse_result.current
|
122
|
+
args = {}
|
123
|
+
::Puppet::Pops::Model::AstTransformer.new('').merge_location(args, model)
|
124
|
+
|
125
|
+
ast_code =
|
126
|
+
if model.is_a? ::Puppet::Pops::Model::Program
|
127
|
+
::Puppet::Parser::AST::PopsBridge::Program.new(model, args)
|
128
|
+
else
|
129
|
+
args[:value] = model
|
130
|
+
::Puppet::Parser::AST::PopsBridge::Expression.new(args)
|
131
|
+
end
|
132
|
+
# Create the "main" class for the content - this content will get merged with all other "main" content
|
133
|
+
::Puppet::Parser::AST::Hostclass.new('', :code => ast_code)
|
134
|
+
end
|
135
|
+
|
136
|
+
# @param String - any valid puppet language code
|
137
|
+
# @return Object - returns either a string of the result or object from puppet evaulation
|
138
|
+
def puppet_eval(input)
|
139
|
+
# in order to add functions to the scope the loaders must be created
|
140
|
+
# in order to call native functions we need to set the global_scope
|
141
|
+
ast = generate_ast(input)
|
142
|
+
Puppet.override( {:global_scope => scope, :loaders => scope.compiler.loaders } , 'For puppet-repl') do
|
143
|
+
# because the repl is not a module we leave the modname blank
|
144
|
+
scope.known_resource_types.import_ast(ast, '')
|
145
|
+
parser.evaluate_string(scope, input)
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
109
149
|
def puppet_lib_dir
|
110
150
|
# returns something like "/Library/Ruby/Gems/2.0.0/gems/puppet-4.2.2/lib/puppet.rb"
|
111
151
|
# this is only useful when returning a namespace with the functions
|
@@ -114,7 +154,7 @@ module PuppetRepl
|
|
114
154
|
|
115
155
|
# returns a future parser for evaluating code
|
116
156
|
def parser
|
117
|
-
@parser
|
157
|
+
@parser ||= ::Puppet::Pops::Parser::EvaluatingParser.new
|
118
158
|
end
|
119
159
|
|
120
160
|
def default_manifests_dir
|
data/lib/version.rb
CHANGED
data/puppet-repl.gemspec
CHANGED
@@ -1,94 +1,36 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
-
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: puppet-repl 0.2.3 ruby lib
|
1
|
+
|
2
|
+
require './lib/version'
|
6
3
|
|
7
4
|
Gem::Specification.new do |s|
|
8
5
|
s.name = "puppet-repl"
|
9
|
-
s.version =
|
10
|
-
|
6
|
+
s.version = PuppetRepl::VERSION
|
7
|
+
s.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|resources|local_test_results|pec)/}) }
|
8
|
+
s.bindir = "bin"
|
9
|
+
s.executables = ["prepl"]
|
10
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
11
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
12
|
+
if s.respond_to?(:metadata)
|
13
|
+
s.metadata['allowed_push_host'] = "'http://mygemserver.com'"
|
14
|
+
else
|
15
|
+
raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
16
|
+
end
|
11
17
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
18
|
s.require_paths = ["lib"]
|
13
19
|
s.authors = ["Corey Osman"]
|
14
|
-
s.date = "2016-
|
20
|
+
s.date = "2016-07-03"
|
15
21
|
s.description = "A interactive command line tool for evaluating the puppet language"
|
16
22
|
s.email = "corey@nwops.io"
|
17
|
-
s.executables = ["prepl"]
|
18
23
|
s.extra_rdoc_files = [
|
19
24
|
"CHANGELOG.md",
|
20
25
|
"LICENSE.txt",
|
21
26
|
"README.md"
|
22
27
|
]
|
23
|
-
s.files = [
|
24
|
-
".document",
|
25
|
-
".gitlab-ci.yml",
|
26
|
-
".rspec",
|
27
|
-
"CHANGELOG.md",
|
28
|
-
"Gemfile",
|
29
|
-
"Gemfile.lock",
|
30
|
-
"LICENSE.txt",
|
31
|
-
"README.md",
|
32
|
-
"Rakefile",
|
33
|
-
"VERSION",
|
34
|
-
"bin/prepl",
|
35
|
-
"lib/awesome_print/ext/awesome_puppet.rb",
|
36
|
-
"lib/puppet-repl.rb",
|
37
|
-
"lib/puppet-repl/cli.rb",
|
38
|
-
"lib/puppet-repl/support.rb",
|
39
|
-
"lib/puppet-repl/support/compiler.rb",
|
40
|
-
"lib/puppet-repl/support/environment.rb",
|
41
|
-
"lib/puppet-repl/support/errors.rb",
|
42
|
-
"lib/puppet-repl/support/facts.rb",
|
43
|
-
"lib/puppet-repl/support/functions.rb",
|
44
|
-
"lib/puppet-repl/support/input_responders.rb",
|
45
|
-
"lib/puppet-repl/support/node.rb",
|
46
|
-
"lib/puppet-repl/support/play.rb",
|
47
|
-
"lib/puppet-repl/support/scope.rb",
|
48
|
-
"lib/trollop.rb",
|
49
|
-
"lib/version.rb",
|
50
|
-
"puppet-repl.gemspec",
|
51
|
-
"resources/classes.png",
|
52
|
-
"resources/classification.png",
|
53
|
-
"resources/command_line_node.png",
|
54
|
-
"resources/functions.png",
|
55
|
-
"resources/hiera.png",
|
56
|
-
"resources/set_node.png",
|
57
|
-
"resources/tab_complete.png",
|
58
|
-
"resources/variables.png",
|
59
|
-
"spec/fixtures/environments/production/manifests/site.pp",
|
60
|
-
"spec/fixtures/invalid_node_obj.yaml",
|
61
|
-
"spec/fixtures/node_obj.yaml",
|
62
|
-
"spec/fixtures/sample_manifest.pp",
|
63
|
-
"spec/prepl_spec.rb",
|
64
|
-
"spec/puppet-repl_spec.rb",
|
65
|
-
"spec/spec_helper.rb",
|
66
|
-
"spec/support_spec.rb"
|
67
|
-
]
|
68
28
|
s.homepage = "http://github.com/nwops/puppet-repl"
|
69
29
|
s.licenses = ["MIT"]
|
70
30
|
s.rubygems_version = "2.4.5.1"
|
71
31
|
s.summary = "A repl for the puppet language"
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
77
|
-
s.add_runtime_dependency(%q<puppet>, [">= 3.8"])
|
78
|
-
s.add_runtime_dependency(%q<facterdb>, ["~> 0.3"])
|
79
|
-
s.add_runtime_dependency(%q<awesome_print>, ["~> 1.6"])
|
80
|
-
s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
|
81
|
-
else
|
82
|
-
s.add_dependency(%q<puppet>, [">= 3.8"])
|
83
|
-
s.add_dependency(%q<facterdb>, ["~> 0.3"])
|
84
|
-
s.add_dependency(%q<awesome_print>, ["~> 1.6"])
|
85
|
-
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
86
|
-
end
|
87
|
-
else
|
88
|
-
s.add_dependency(%q<puppet>, [">= 3.8"])
|
89
|
-
s.add_dependency(%q<facterdb>, ["~> 0.3"])
|
90
|
-
s.add_dependency(%q<awesome_print>, ["~> 1.6"])
|
91
|
-
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
92
|
-
end
|
32
|
+
s.add_runtime_dependency(%q<puppet>, [">= 3.8"])
|
33
|
+
s.add_runtime_dependency(%q<facterdb>, ["~> 0.3"])
|
34
|
+
s.add_runtime_dependency(%q<awesome_print>, ["~> 1.6"])
|
35
|
+
s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
|
93
36
|
end
|
94
|
-
|
@@ -0,0 +1,12 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
export PATH=$PATH:/usr/local/bundle
|
3
|
+
gem install bundler > /dev/null
|
4
|
+
gem update --system > /dev/null
|
5
|
+
bundle install --no-color --without development
|
6
|
+
bundle exec puppet module install puppetlabs-stdlib
|
7
|
+
echo "Running tests, output to ${OUT_DIR}/results.txt"
|
8
|
+
bundle exec rspec --out "${OUT_DIR}/results.txt" --format documentation
|
9
|
+
# due to concurrency issues we can't build this in parallel
|
10
|
+
#gem build puppet-repl.gemspec
|
11
|
+
|
12
|
+
# docker run -e RUBY_VERSION='ruby:1.9.3' -e PUPPET_GEM_VERSION='~> 3.8' --rm -ti -v ${PWD}:/module --workdir /module ruby:1.9.3 /bin/bash run_container_test.sh
|