puppet-module 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.
- data/CHANGES.markdown +91 -0
- data/LICENSE +17 -0
- data/README.markdown +221 -0
- data/Rakefile +87 -0
- data/VERSION +1 -0
- data/bin/puppet-module +7 -0
- data/lib/puppet/module/tool.rb +124 -0
- data/lib/puppet/module/tool/applications.rb +18 -0
- data/lib/puppet/module/tool/applications/application.rb +83 -0
- data/lib/puppet/module/tool/applications/builder.rb +88 -0
- data/lib/puppet/module/tool/applications/checksummer.rb +38 -0
- data/lib/puppet/module/tool/applications/cleaner.rb +14 -0
- data/lib/puppet/module/tool/applications/freezer.rb +20 -0
- data/lib/puppet/module/tool/applications/generator.rb +117 -0
- data/lib/puppet/module/tool/applications/installer.rb +83 -0
- data/lib/puppet/module/tool/applications/registrar.rb +34 -0
- data/lib/puppet/module/tool/applications/releaser.rb +48 -0
- data/lib/puppet/module/tool/applications/searcher.rb +34 -0
- data/lib/puppet/module/tool/applications/unpacker.rb +69 -0
- data/lib/puppet/module/tool/applications/unreleaser.rb +42 -0
- data/lib/puppet/module/tool/cache.rb +56 -0
- data/lib/puppet/module/tool/checksums.rb +52 -0
- data/lib/puppet/module/tool/cli.rb +127 -0
- data/lib/puppet/module/tool/contents_description.rb +84 -0
- data/lib/puppet/module/tool/dependency.rb +26 -0
- data/lib/puppet/module/tool/metadata.rb +80 -0
- data/lib/puppet/module/tool/modulefile.rb +47 -0
- data/lib/puppet/module/tool/repository.rb +74 -0
- data/lib/puppet/module/tool/skeleton.rb +39 -0
- data/lib/puppet/module/tool/utils.rb +9 -0
- data/lib/puppet/module/tool/utils/interrogation.rb +39 -0
- data/lib/puppet/module/tool/utils/settings.rb +36 -0
- data/lib/puppet/module/tool/utils/uri.rb +16 -0
- data/spec/fixtures/releases/jamtur01-apache/Modulefile +2 -0
- data/spec/fixtures/releases/jamtur01-apache/files/httpd +24 -0
- data/spec/fixtures/releases/jamtur01-apache/files/test.vhost +18 -0
- data/spec/fixtures/releases/jamtur01-apache/lib/puppet/provider/a2mod/debian.rb +21 -0
- data/spec/fixtures/releases/jamtur01-apache/lib/puppet/type/a2mod.rb +12 -0
- data/spec/fixtures/releases/jamtur01-apache/manifests/dev.pp +5 -0
- data/spec/fixtures/releases/jamtur01-apache/manifests/init.pp +34 -0
- data/spec/fixtures/releases/jamtur01-apache/manifests/params.pp +17 -0
- data/spec/fixtures/releases/jamtur01-apache/manifests/php.pp +5 -0
- data/spec/fixtures/releases/jamtur01-apache/manifests/ssl.pp +15 -0
- data/spec/fixtures/releases/jamtur01-apache/manifests/vhost.pp +15 -0
- data/spec/fixtures/releases/jamtur01-apache/metadata.json +1 -0
- data/spec/fixtures/releases/jamtur01-apache/templates/vhost-default.conf.erb +20 -0
- data/spec/fixtures/releases/jamtur01-apache/tests/apache.pp +1 -0
- data/spec/fixtures/releases/jamtur01-apache/tests/dev.pp +1 -0
- data/spec/fixtures/releases/jamtur01-apache/tests/init.pp +1 -0
- data/spec/fixtures/releases/jamtur01-apache/tests/php.pp +1 -0
- data/spec/fixtures/releases/jamtur01-apache/tests/ssl.pp +1 -0
- data/spec/fixtures/releases/jamtur01-apache/tests/vhost.pp +2 -0
- data/spec/integration/cli_spec.rb +373 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +15 -0
- data/spec/support/output_support.rb +19 -0
- data/spec/support/stub_http_support.rb +14 -0
- data/spec/support/testdir_support.rb +26 -0
- data/spec/unit/application_spec.rb +25 -0
- data/spec/unit/repository_spec.rb +51 -0
- data/templates/generator/Modulefile.erb +5 -0
- data/templates/generator/README.erb +3 -0
- data/templates/generator/files/README.markdown +22 -0
- data/templates/generator/lib/puppet/facter/README.markdown +22 -0
- data/templates/generator/lib/puppet/parser/functions/README.markdown +17 -0
- data/templates/generator/lib/puppet/provider/README.markdown +14 -0
- data/templates/generator/lib/puppet/type/README.markdown +14 -0
- data/templates/generator/manifests/README.markdown +28 -0
- data/templates/generator/manifests/init.pp.erb +17 -0
- data/templates/generator/metadata.json +12 -0
- data/templates/generator/spec/README.markdown +7 -0
- data/templates/generator/spec/spec.opts +6 -0
- data/templates/generator/spec/spec_helper.rb +18 -0
- data/templates/generator/spec/unit/puppet/provider/README.markdown +4 -0
- data/templates/generator/spec/unit/puppet/type/README.markdown +4 -0
- data/templates/generator/templates/README.markdown +23 -0
- data/templates/generator/tests/init.pp.erb +1 -0
- data/vendor/facets-2.8.2-partial/lib/facets/kernel/returning.rb +23 -0
- data/vendor/facets-2.8.2-partial/lib/facets/kernel/tap.rb +39 -0
- data/vendor/multipart-post-1.0/Manifest.txt +9 -0
- data/vendor/multipart-post-1.0/README.txt +61 -0
- data/vendor/multipart-post-1.0/Rakefile +21 -0
- data/vendor/multipart-post-1.0/lib/composite_io.rb +89 -0
- data/vendor/multipart-post-1.0/lib/multipartable.rb +13 -0
- data/vendor/multipart-post-1.0/lib/net/http/post/multipart.rb +27 -0
- data/vendor/multipart-post-1.0/lib/parts.rb +66 -0
- data/vendor/multipart-post-1.0/test/net/http/post/test_multipart.rb +55 -0
- data/vendor/multipart-post-1.0/test/test_composite_io.rb +50 -0
- data/vendor/thor-852190ae/CHANGELOG.rdoc +89 -0
- data/vendor/thor-852190ae/LICENSE +20 -0
- data/vendor/thor-852190ae/README.rdoc +297 -0
- data/vendor/thor-852190ae/REVISION +1 -0
- data/vendor/thor-852190ae/Thorfile +69 -0
- data/vendor/thor-852190ae/bin/rake2thor +86 -0
- data/vendor/thor-852190ae/bin/thor +6 -0
- data/vendor/thor-852190ae/lib/thor.rb +244 -0
- data/vendor/thor-852190ae/lib/thor/actions.rb +275 -0
- data/vendor/thor-852190ae/lib/thor/actions/create_file.rb +103 -0
- data/vendor/thor-852190ae/lib/thor/actions/directory.rb +91 -0
- data/vendor/thor-852190ae/lib/thor/actions/empty_directory.rb +134 -0
- data/vendor/thor-852190ae/lib/thor/actions/file_manipulation.rb +223 -0
- data/vendor/thor-852190ae/lib/thor/actions/inject_into_file.rb +104 -0
- data/vendor/thor-852190ae/lib/thor/base.rb +540 -0
- data/vendor/thor-852190ae/lib/thor/core_ext/file_binary_read.rb +9 -0
- data/vendor/thor-852190ae/lib/thor/core_ext/hash_with_indifferent_access.rb +75 -0
- data/vendor/thor-852190ae/lib/thor/core_ext/ordered_hash.rb +100 -0
- data/vendor/thor-852190ae/lib/thor/error.rb +30 -0
- data/vendor/thor-852190ae/lib/thor/group.rb +271 -0
- data/vendor/thor-852190ae/lib/thor/invocation.rb +180 -0
- data/vendor/thor-852190ae/lib/thor/parser.rb +4 -0
- data/vendor/thor-852190ae/lib/thor/parser/argument.rb +67 -0
- data/vendor/thor-852190ae/lib/thor/parser/arguments.rb +150 -0
- data/vendor/thor-852190ae/lib/thor/parser/option.rb +128 -0
- data/vendor/thor-852190ae/lib/thor/parser/options.rb +169 -0
- data/vendor/thor-852190ae/lib/thor/rake_compat.rb +66 -0
- data/vendor/thor-852190ae/lib/thor/runner.rb +314 -0
- data/vendor/thor-852190ae/lib/thor/shell.rb +83 -0
- data/vendor/thor-852190ae/lib/thor/shell/basic.rb +239 -0
- data/vendor/thor-852190ae/lib/thor/shell/color.rb +108 -0
- data/vendor/thor-852190ae/lib/thor/task.rb +102 -0
- data/vendor/thor-852190ae/lib/thor/util.rb +230 -0
- data/vendor/thor-852190ae/lib/thor/version.rb +3 -0
- data/vendor/thor-852190ae/spec/actions/create_file_spec.rb +170 -0
- data/vendor/thor-852190ae/spec/actions/directory_spec.rb +131 -0
- data/vendor/thor-852190ae/spec/actions/empty_directory_spec.rb +91 -0
- data/vendor/thor-852190ae/spec/actions/file_manipulation_spec.rb +271 -0
- data/vendor/thor-852190ae/spec/actions/inject_into_file_spec.rb +135 -0
- data/vendor/thor-852190ae/spec/actions_spec.rb +292 -0
- data/vendor/thor-852190ae/spec/base_spec.rb +263 -0
- data/vendor/thor-852190ae/spec/core_ext/hash_with_indifferent_access_spec.rb +43 -0
- data/vendor/thor-852190ae/spec/core_ext/ordered_hash_spec.rb +115 -0
- data/vendor/thor-852190ae/spec/fixtures/application.rb +2 -0
- data/vendor/thor-852190ae/spec/fixtures/bundle/execute.rb +6 -0
- data/vendor/thor-852190ae/spec/fixtures/bundle/main.thor +1 -0
- data/vendor/thor-852190ae/spec/fixtures/doc/%file_name%.rb.tt +1 -0
- data/vendor/thor-852190ae/spec/fixtures/doc/README +3 -0
- data/vendor/thor-852190ae/spec/fixtures/doc/config.rb +1 -0
- data/vendor/thor-852190ae/spec/fixtures/group.thor +83 -0
- data/vendor/thor-852190ae/spec/fixtures/invoke.thor +112 -0
- data/vendor/thor-852190ae/spec/fixtures/script.thor +140 -0
- data/vendor/thor-852190ae/spec/fixtures/task.thor +10 -0
- data/vendor/thor-852190ae/spec/group_spec.rb +171 -0
- data/vendor/thor-852190ae/spec/invocation_spec.rb +107 -0
- data/vendor/thor-852190ae/spec/parser/argument_spec.rb +47 -0
- data/vendor/thor-852190ae/spec/parser/arguments_spec.rb +64 -0
- data/vendor/thor-852190ae/spec/parser/option_spec.rb +202 -0
- data/vendor/thor-852190ae/spec/parser/options_spec.rb +292 -0
- data/vendor/thor-852190ae/spec/rake_compat_spec.rb +68 -0
- data/vendor/thor-852190ae/spec/runner_spec.rb +202 -0
- data/vendor/thor-852190ae/spec/shell/basic_spec.rb +205 -0
- data/vendor/thor-852190ae/spec/shell/color_spec.rb +41 -0
- data/vendor/thor-852190ae/spec/shell_spec.rb +34 -0
- data/vendor/thor-852190ae/spec/spec.opts +1 -0
- data/vendor/thor-852190ae/spec/spec_helper.rb +54 -0
- data/vendor/thor-852190ae/spec/task_spec.rb +69 -0
- data/vendor/thor-852190ae/spec/thor_spec.rb +237 -0
- data/vendor/thor-852190ae/spec/util_spec.rb +167 -0
- data/vendor/thor-852190ae/thor.gemspec +120 -0
- metadata +229 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
module Puppet::Module::Tool
|
|
2
|
+
module Applications
|
|
3
|
+
|
|
4
|
+
class Registrar < Application
|
|
5
|
+
# TODO Review whether the 'register' feature should be fixed or deleted.
|
|
6
|
+
=begin
|
|
7
|
+
def initialize(full_name, options = {})
|
|
8
|
+
@full_name = full_name
|
|
9
|
+
@username, @module_name = full_name.split(/[\/\-]/, 2)
|
|
10
|
+
super(options)
|
|
11
|
+
validate!
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def run
|
|
15
|
+
if confirms?("Register #{@full_name}?")
|
|
16
|
+
request = Net::HTTP::Post.new("/users/#{@username}/modules.json")
|
|
17
|
+
request.set_form_data 'mod[name]' => @module_name
|
|
18
|
+
response = repository.contact(request, :authenticate => true)
|
|
19
|
+
discuss response, "Registered #{@full_name}", "Could not register #{@full_name}"
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
private
|
|
24
|
+
|
|
25
|
+
def validate!
|
|
26
|
+
unless @username && @module_name
|
|
27
|
+
abort "Must provide the full module name (ie, 'username/name') to register."
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
=end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
require 'net/http/post/multipart'
|
|
2
|
+
|
|
3
|
+
module Puppet::Module::Tool
|
|
4
|
+
|
|
5
|
+
module Applications
|
|
6
|
+
|
|
7
|
+
class Releaser < Application
|
|
8
|
+
# TODO Review whether the 'release' feature should be fixed or deleted.
|
|
9
|
+
=begin
|
|
10
|
+
def initialize(filename, options = {})
|
|
11
|
+
@filename = filename
|
|
12
|
+
parse_filename!
|
|
13
|
+
super(options)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def version
|
|
17
|
+
@version ||= options[:version]
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def run
|
|
21
|
+
upload if confirms?("Release #{File.basename(@filename)} as version #{version} of #{@username}/#{@module_name}?")
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
private
|
|
25
|
+
|
|
26
|
+
def upload
|
|
27
|
+
File.open(@filename) do |file|
|
|
28
|
+
request = build_request(file)
|
|
29
|
+
response = repository.contact(request, :authenticate => true)
|
|
30
|
+
discuss response, "Released #{version}", "Could not release #{version}"
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def build_request(file)
|
|
35
|
+
upload = UploadIO.new(file, 'application/x-gzip', @filename)
|
|
36
|
+
Net::HTTP::Post::Multipart.new(upload_path,
|
|
37
|
+
'release[version]' => version,
|
|
38
|
+
'release[file]' => upload)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def upload_path
|
|
42
|
+
"/users/#{@username}/modules/#{@module_name}/releases.json"
|
|
43
|
+
end
|
|
44
|
+
=end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
end
|
|
48
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
module Puppet::Module::Tool
|
|
2
|
+
|
|
3
|
+
module Applications
|
|
4
|
+
|
|
5
|
+
class Searcher < Application
|
|
6
|
+
|
|
7
|
+
def initialize(term, options = {})
|
|
8
|
+
@term = term
|
|
9
|
+
super(options)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def run
|
|
13
|
+
header "Searching #{repository}"
|
|
14
|
+
request = Net::HTTP::Get.new("/modules.json?q=#{URI.escape(@term)}")
|
|
15
|
+
response = repository.contact(request)
|
|
16
|
+
case response
|
|
17
|
+
when Net::HTTPOK
|
|
18
|
+
matches = PSON.parse(response.body)
|
|
19
|
+
if matches.empty?
|
|
20
|
+
subheader "0 found."
|
|
21
|
+
else
|
|
22
|
+
subheader "#{matches.size} found."
|
|
23
|
+
end
|
|
24
|
+
matches.each do |match|
|
|
25
|
+
puts "#{match['full_name']} (#{match['version']})"
|
|
26
|
+
end
|
|
27
|
+
else
|
|
28
|
+
say "Could not execute search (HTTP #{response.code})"
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
require 'pathname'
|
|
2
|
+
require 'tmpdir'
|
|
3
|
+
|
|
4
|
+
module Puppet::Module::Tool
|
|
5
|
+
|
|
6
|
+
module Applications
|
|
7
|
+
|
|
8
|
+
class Unpacker < Application
|
|
9
|
+
|
|
10
|
+
def initialize(filename, environment_path, options = {})
|
|
11
|
+
@filename = Pathname.new(filename)
|
|
12
|
+
@environment_path = Pathname.new(environment_path)
|
|
13
|
+
parse_filename!
|
|
14
|
+
super(options)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def force?
|
|
18
|
+
options[:force]
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def run
|
|
22
|
+
check_clobber!
|
|
23
|
+
build_dir = Puppet::Module::Tool::Cache.base_path + "tmp-unpacker-#{Digest::SHA1.hexdigest(@filename.basename)}"
|
|
24
|
+
build_dir.mkpath
|
|
25
|
+
begin
|
|
26
|
+
FileUtils.cp @filename, build_dir
|
|
27
|
+
Dir.chdir(build_dir) do
|
|
28
|
+
unless system "tar xzf #{@filename.basename}"
|
|
29
|
+
abort "Could not extract contents of module archive."
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
# grab the first directory
|
|
33
|
+
extracted = build_dir.children.detect { |c| c.directory? }
|
|
34
|
+
if force?
|
|
35
|
+
FileUtils.rm_rf @full_name rescue nil
|
|
36
|
+
end
|
|
37
|
+
FileUtils.cp_r extracted, @full_name
|
|
38
|
+
tag_revision
|
|
39
|
+
ensure
|
|
40
|
+
build_dir.rmtree
|
|
41
|
+
end
|
|
42
|
+
say "Installed #{@release_name.inspect} into directory: #{@full_name}"
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
private
|
|
46
|
+
|
|
47
|
+
def tag_revision
|
|
48
|
+
File.open("#{@full_name}/REVISION", 'w') do |f|
|
|
49
|
+
f.puts "module: #{@username}/#{@module_name}"
|
|
50
|
+
f.puts "version: #{@version}"
|
|
51
|
+
f.puts "url: file://#{@filename.realpath}"
|
|
52
|
+
f.puts "installed: #{Time.now}"
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def check_clobber!
|
|
57
|
+
if File.directory?(@full_name) && !force?
|
|
58
|
+
header "Existing module '#{@full_name}' found"
|
|
59
|
+
response = prompt "Overwrite module installed at ./#{@full_name}? [y/N]"
|
|
60
|
+
unless response =~ /y/i
|
|
61
|
+
abort "Aborted installation."
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
end
|
|
69
|
+
end
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
module Puppet::Module::Tool
|
|
2
|
+
module Applications
|
|
3
|
+
|
|
4
|
+
class Unreleaser < Application
|
|
5
|
+
# TODO Review whether the 'unrelease' feature should be fixed or deleted.
|
|
6
|
+
=begin
|
|
7
|
+
def initialize(address, options = {})
|
|
8
|
+
@address = address
|
|
9
|
+
@username, @module_name = address.split('/')
|
|
10
|
+
validate!
|
|
11
|
+
super(options)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def version
|
|
15
|
+
options[:version]
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def run
|
|
19
|
+
if confirms?("Unrelease #{@address} #{version}?")
|
|
20
|
+
request = Net::HTTP::Delete.new("/users/#{@username}/modules/#{@module_name}/releases/#{version}")
|
|
21
|
+
response = repository.contact(request, :authenticate => true)
|
|
22
|
+
discuss response, "Unreleased #{@address} #{version}", "Could not unrelease #{@address} #{version}"
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
private
|
|
27
|
+
|
|
28
|
+
def validate!
|
|
29
|
+
unless @username && @module_name
|
|
30
|
+
abort "Username and Module name not provided"
|
|
31
|
+
end
|
|
32
|
+
begin
|
|
33
|
+
Gem::Version.new(version)
|
|
34
|
+
rescue ArgumentError => e
|
|
35
|
+
abort "Invalid version format: #{version}"
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
=end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
end
|
|
42
|
+
end
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
module Puppet::Module::Tool
|
|
2
|
+
|
|
3
|
+
# = Cache
|
|
4
|
+
#
|
|
5
|
+
# Provides methods for reading files from local cache, filesystem or network.
|
|
6
|
+
class Cache
|
|
7
|
+
include Puppet::Module::Tool::Utils::URI
|
|
8
|
+
|
|
9
|
+
# Instantiate new cahe for the +repositry+ instance.
|
|
10
|
+
def initialize(repository)
|
|
11
|
+
@repository = repository
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
# Return filename retrieved from +uri+ instance. Will download this file and
|
|
15
|
+
# cache it if needed.
|
|
16
|
+
#
|
|
17
|
+
# TODO: Add checksum support.
|
|
18
|
+
# TODO: Add error checking.
|
|
19
|
+
def retrieve(url)
|
|
20
|
+
returning(path + File.basename(url.to_s)) do |cached_file|
|
|
21
|
+
uri = normalize(url)
|
|
22
|
+
unless cached_file.file?
|
|
23
|
+
if uri.scheme == 'file'
|
|
24
|
+
FileUtils.cp(uri.path, cached_file)
|
|
25
|
+
else
|
|
26
|
+
# TODO: Handle HTTPS; probably should use repository.contact
|
|
27
|
+
data = read_retrieve(uri)
|
|
28
|
+
cached_file.open('wb') { |f| f.write data }
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# Return contents of file at the given URI's +uri+.
|
|
35
|
+
def read_retrieve(uri)
|
|
36
|
+
return uri.read
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# Return Pathname for repository's cache directory, create it if needed.
|
|
40
|
+
def path
|
|
41
|
+
return @path ||= (self.class.base_path + @repository.cache_key).tap{ |o| o.mkpath }
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# Return the base Pathname for all the caches.
|
|
45
|
+
def self.base_path
|
|
46
|
+
return(Puppet::Module::Tool.working_dir + 'cache')
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# Clean out all the caches.
|
|
50
|
+
def self.clean
|
|
51
|
+
base_path.rmtree if base_path.exist?
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
end
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
require 'digest/md5'
|
|
2
|
+
|
|
3
|
+
module Puppet::Module::Tool
|
|
4
|
+
|
|
5
|
+
# = Checksums
|
|
6
|
+
#
|
|
7
|
+
# This class proides methods for generating checksums for data and adding
|
|
8
|
+
# them to +Metadata+.
|
|
9
|
+
class Checksums
|
|
10
|
+
include Enumerable
|
|
11
|
+
|
|
12
|
+
# Instantiate object with string +path+ to create checksums from.
|
|
13
|
+
def initialize(path)
|
|
14
|
+
@path = Pathname.new(path)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
# Return checksum for the +Pathname+.
|
|
18
|
+
def checksum(pathname)
|
|
19
|
+
return Digest::MD5.hexdigest(pathname.read)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# Return checksums for object's +Pathname+, generate if it's needed.
|
|
23
|
+
# Result is a hash of path strings to checksum strings.
|
|
24
|
+
def data
|
|
25
|
+
unless @data
|
|
26
|
+
@data = {}
|
|
27
|
+
@path.find do |descendant|
|
|
28
|
+
if Puppet::Module::Tool.artifact?(descendant)
|
|
29
|
+
Find.prune
|
|
30
|
+
elsif descendant.file?
|
|
31
|
+
path = descendant.relative_path_from(@path)
|
|
32
|
+
@data[path.to_s] = checksum(descendant)
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
return @data
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# TODO: Why?
|
|
40
|
+
def each(&block)
|
|
41
|
+
data.each(&block)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# Update +Metadata+'s checksums with this object's.
|
|
45
|
+
def annotate(metadata)
|
|
46
|
+
metadata.checksums.replace(data)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# TODO: Move the Checksummer#run checksum checking to here?
|
|
50
|
+
|
|
51
|
+
end
|
|
52
|
+
end
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
begin
|
|
2
|
+
require 'thor'
|
|
3
|
+
rescue LoadError
|
|
4
|
+
abort "Requires 'thor'"
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
# = CLI
|
|
8
|
+
#
|
|
9
|
+
# This class is used by the command-line program to dispatch actions.
|
|
10
|
+
class Puppet::Module::Tool::CLI < Thor
|
|
11
|
+
include Thor::Actions
|
|
12
|
+
|
|
13
|
+
map '-V' => :version
|
|
14
|
+
|
|
15
|
+
class_option :config, :aliases => '-c', :default => Puppet.settings[:config], :desc => "Configuration file"
|
|
16
|
+
|
|
17
|
+
def self.method_option_repository
|
|
18
|
+
method_option :puppet_module_repository, :aliases => '-r', :default => Puppet.settings[:puppet_module_repository], :desc => "Module repository to use"
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
desc "version", "Show the version information for this tool"
|
|
22
|
+
def version
|
|
23
|
+
say Puppet::Module::Tool.version
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
desc "generate USERNAME-MODNAME", "Generate boilerplate for a new module"
|
|
27
|
+
method_option_repository
|
|
28
|
+
def generate(name)
|
|
29
|
+
Puppet::Module::Tool::Applications::Generator.run(name, options)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# TODO Review whether the 'freeze' feature should be fixed or deleted.
|
|
33
|
+
# desc "freeze", "Freeze the module skeleton (to customize for `generate`)"
|
|
34
|
+
# def freeze
|
|
35
|
+
# Puppet::Module::Tool::Applications::Freezer.run(options)
|
|
36
|
+
# end
|
|
37
|
+
|
|
38
|
+
desc "clean", "Clears module cache for all repositories"
|
|
39
|
+
def clean
|
|
40
|
+
Puppet::Module::Tool::Applications::Cleaner.run(options)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
desc "build [PATH_TO_MODULE]", "Build a module for release"
|
|
44
|
+
def build(path = nil)
|
|
45
|
+
Puppet::Module::Tool::Applications::Builder.run(find_module_root(path), options)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# TODO Review whether the 'release' feature should be fixed or deleted.
|
|
49
|
+
# desc "release FILENAME", "Release a module tarball (.tar.gz)"
|
|
50
|
+
# method_option_repository
|
|
51
|
+
# def release(filename)
|
|
52
|
+
# Puppet::Module::Tool::Applications::Releaser.run(filename, options)
|
|
53
|
+
# end
|
|
54
|
+
|
|
55
|
+
# TODO Review whether the 'unrelease' feature should be fixed or deleted.
|
|
56
|
+
# desc "unrelease MODULE_NAME", "Unrelease a module (eg, 'user-modname')"
|
|
57
|
+
# method_option :version, :alias => :v, :required => true, :desc => "The version to unrelease"
|
|
58
|
+
# method_option_repository
|
|
59
|
+
# def unrelease(module_name)
|
|
60
|
+
# Puppet::Module::Tool::Applications::Unreleaser.run(module_name,
|
|
61
|
+
# options)
|
|
62
|
+
# end
|
|
63
|
+
|
|
64
|
+
desc "install MODULE_NAME_OR_FILE [OPTIONS]", "Install a module (eg, 'user-modname') from a repository or file"
|
|
65
|
+
method_option :version, :alias => :v, :desc => "Version to install (can be a requirement, eg '>= 1.0.3', defaults to latest version)"
|
|
66
|
+
method_option :force, :alias => :f, :type => :boolean, :desc => "Force overwrite of existing module, if any"
|
|
67
|
+
method_option_repository
|
|
68
|
+
def install(name)
|
|
69
|
+
Puppet::Module::Tool::Applications::Installer.run(name, options)
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
desc "search TERM", "Search the module repository for a module matching TERM"
|
|
73
|
+
method_option_repository
|
|
74
|
+
def search(term)
|
|
75
|
+
Puppet::Module::Tool::Applications::Searcher.run(term, options)
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
# TODO Review whether the 'register' feature should be fixed or deleted.
|
|
79
|
+
# desc "register MODULE_NAME", "Register a new module (eg, 'user-modname')"
|
|
80
|
+
# method_option_repository
|
|
81
|
+
# def register(module_name)
|
|
82
|
+
# Puppet::Module::Tool::Applications::Registrar.run(module_name, options)
|
|
83
|
+
# end
|
|
84
|
+
|
|
85
|
+
desc "changes [PATH_TO_MODULE]", "Show modified files in an installed module"
|
|
86
|
+
def changes(path = nil)
|
|
87
|
+
Puppet::Module::Tool::Applications::Checksummer.run(find_module_root(path), options)
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
desc "repository", "Show currently configured repository"
|
|
91
|
+
def repository
|
|
92
|
+
Puppet::Module::Tool.prepare_settings(options)
|
|
93
|
+
say Puppet.settings[:puppet_module_repository]
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
desc "usage", "Display detailed usage documentation for this tool"
|
|
97
|
+
def usage
|
|
98
|
+
Puppet::Module::Tool.prepare_settings(options)
|
|
99
|
+
if ENV['PAGER']
|
|
100
|
+
exec ENV['PAGER'], Puppet::Module::Tool.usage_filename
|
|
101
|
+
else
|
|
102
|
+
puts File.read(Puppet::Module::Tool.usage_filename)
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
desc "changelog", "Display the changelog for this tool"
|
|
107
|
+
def changelog
|
|
108
|
+
Puppet::Module::Tool.prepare_settings(options)
|
|
109
|
+
if ENV['PAGER']
|
|
110
|
+
exec ENV['PAGER'], Puppet::Module::Tool.changelog_filename
|
|
111
|
+
else
|
|
112
|
+
puts File.read(Puppet::Module::Tool.changelog_filename)
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
no_tasks do
|
|
117
|
+
def find_module_root(path)
|
|
118
|
+
for dir in [path, Dir.pwd].compact
|
|
119
|
+
if File.exist?(File.join(dir, 'Modulefile'))
|
|
120
|
+
return dir
|
|
121
|
+
end
|
|
122
|
+
end
|
|
123
|
+
abort "Could not find a valid module at #{path ? path.inspect : 'current directory'}"
|
|
124
|
+
end
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
end
|