generate-puppetfile 0.9.4 → 0.9.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/generate_puppetfile/bin.rb +40 -1
- data/lib/generate_puppetfile/optparser.rb +26 -15
- data/lib/generate_puppetfile/version.rb +1 -1
- metadata +15 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MmFiNzJhMGJlNTc1YjJmZWFiZjhhYzdmYTMzZDAwMTljNjg1ODk5Zg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YWFmZTE1ZDQ4ZDI5MGYzYTQzNDYzNjY1ZGIwMTliMTJiMmEwYTY4NA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
OWI2YzdhN2E4YjJiNzNhNjY0ZjY5YzU5YjI3NDZiMjllMGI5Nzg3MWFkZDZh
|
10
|
+
N2NlMGJhYWVlNTk1NDAyMzgxYzlmZTY4MzNkYTFhNDQ4ODI3MTVhMmY4NTQ3
|
11
|
+
MGMxODE2NmE4OWQxNDdjNzdjMzhlMDg5NTI1ODZiYmZjYjdmM2U=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MDU4YzdhZDZkZGY5YjdjYWViODVhNWVlN2I3NjZhNzE5NTk2YTM3YmIyODll
|
14
|
+
Y2RlOWY1NDEwNTJhYmRjZjgwZjFkODUxZjAyNWIwYTY3ZjlhZGExZjI4ODZj
|
15
|
+
YzVhMTRhMzA2ZWRmNzU5NjI1YjZkOTU0NzAzYWRjYTE1MjA4NzA=
|
@@ -3,6 +3,7 @@ require 'generate_puppetfile'
|
|
3
3
|
require 'generate_puppetfile/optparser'
|
4
4
|
require 'fileutils'
|
5
5
|
require 'tempfile'
|
6
|
+
require 'json'
|
6
7
|
|
7
8
|
module GeneratePuppetfile
|
8
9
|
# Internal: The Bin class contains the logic for calling generate_puppetfile at the command line
|
@@ -57,7 +58,6 @@ module GeneratePuppetfile
|
|
57
58
|
|
58
59
|
forge_module_list.push(*cli_modules) if @args
|
59
60
|
forge_module_list.push(*puppetfile_contents[:modules]) if puppetfile_contents[:modules]
|
60
|
-
|
61
61
|
list_forge_modules(forge_module_list) if puppetfile_contents && @options[:debug]
|
62
62
|
list_extras(puppetfile_contents[:extras]) if puppetfile_contents[:extras] && @options[:debug]
|
63
63
|
|
@@ -81,6 +81,11 @@ module GeneratePuppetfile
|
|
81
81
|
display_puppetfile(puppetfile_contents)
|
82
82
|
end
|
83
83
|
|
84
|
+
if @options[:create_fixtures]
|
85
|
+
fixtures_data = generate_fixtures_data()
|
86
|
+
write_fixtures_data(fixtures_data)
|
87
|
+
end
|
88
|
+
|
84
89
|
cleanup_workspace()
|
85
90
|
|
86
91
|
return 0
|
@@ -219,5 +224,39 @@ forge 'http://forge.puppetlabs.com'
|
|
219
224
|
def cleanup_workspace ()
|
220
225
|
FileUtils.rm_rf(@workspace)
|
221
226
|
end
|
227
|
+
|
228
|
+
# Public: Generate a simple fixtures file.
|
229
|
+
def generate_fixtures_data ()
|
230
|
+
puts "\nGenerating .fixtures.yml using module name #{@options[:modulename]}" unless @options[:silent]
|
231
|
+
|
232
|
+
# Header for fixtures file creates a symlink for the current module"
|
233
|
+
fixtures_data = <<-EOF
|
234
|
+
fixtures:
|
235
|
+
symlinks:
|
236
|
+
#{@options[:modulename]}: "\#{source_dir}"
|
237
|
+
EOF
|
238
|
+
|
239
|
+
|
240
|
+
module_directories = Dir.glob("#{@workspace}/*")
|
241
|
+
if (module_directories != [])
|
242
|
+
fixtures_data += " repositories:\n"
|
243
|
+
end
|
244
|
+
module_directories.each do |module_directory|
|
245
|
+
name = File.basename(module_directory)
|
246
|
+
file = File.read("#{module_directory}/metadata.json")
|
247
|
+
project_page = (JSON.parse(file))["project_page"]
|
248
|
+
fixtures_data += " #{name}: #{project_page}\n"
|
249
|
+
puts "Found a module '#{name}' with a project page of #{project_page}." if @options[:debug]
|
250
|
+
end unless module_directories == []
|
251
|
+
|
252
|
+
fixtures_data
|
253
|
+
end
|
254
|
+
|
255
|
+
def write_fixtures_data (data)
|
256
|
+
File.open('.fixtures.yml', 'w') do |file|
|
257
|
+
file.write data
|
258
|
+
end
|
259
|
+
end
|
260
|
+
|
222
261
|
end
|
223
262
|
end
|
@@ -9,6 +9,9 @@ module GeneratePuppetfile
|
|
9
9
|
# Returns an OptionParser object.
|
10
10
|
def self.parse(args)
|
11
11
|
options = {}
|
12
|
+
# Default values
|
13
|
+
options[:modulename] = 'profile'
|
14
|
+
|
12
15
|
opts = OptionParser.new do |opts|
|
13
16
|
opts.banner = "generate-puppetfile [OPTIONS] [<MODULE> ... <MODULE>]"
|
14
17
|
|
@@ -18,26 +21,34 @@ module GeneratePuppetfile
|
|
18
21
|
exit 1
|
19
22
|
end
|
20
23
|
|
21
|
-
|
24
|
+
options[:puppetfile] = file
|
22
25
|
end
|
23
26
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
+
opts.on('-c', '--create_puppetfile', 'Create a Puppetfile in the working directory. Warning: overwrites any existing file with the same name.') do
|
28
|
+
options[:create_puppetfile] = true
|
29
|
+
end
|
27
30
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
end
|
31
|
+
opts.on('-f', '--fixtures', 'Create a .fixtures.yml file in the working directory. Somewhat naive.') do
|
32
|
+
options[:create_fixtures] = true
|
33
|
+
end
|
32
34
|
|
33
|
-
|
34
|
-
|
35
|
-
|
35
|
+
opts.on('-m', '--modulename NAME', "Name of the module the fixtures file will be used with. Optional. Defaults to 'profile'.") do |name|
|
36
|
+
options[:modulename] = name
|
37
|
+
end
|
36
38
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
39
|
+
opts.on('-s', '--silent', 'Run in silent mode. Supresses all non-debug output. Adds the -c flag automatically.') do
|
40
|
+
options[:silent] = true
|
41
|
+
options[:create_puppetfile] = true
|
42
|
+
end
|
43
|
+
|
44
|
+
opts.on('-d', '--debug', 'Enable debug logging') do
|
45
|
+
options[:debug] = true
|
46
|
+
end
|
47
|
+
|
48
|
+
opts.on_tail('-v', '--version', 'Show version') do
|
49
|
+
puts "generate-puppetfile v#{GeneratePuppetfile::VERSION}"
|
50
|
+
exit
|
51
|
+
end
|
41
52
|
end
|
42
53
|
|
43
54
|
opts.parse!(args)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: generate-puppetfile
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rob Nelson
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - ~>
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '1'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: json
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1'
|
55
69
|
description: Generate a Puppetfile for use with r10k based on an existing file or
|
56
70
|
a list of modules.
|
57
71
|
email: rnelson0@gmail.com
|