puppet-moddeps 1.2.0 → 2.0.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 +5 -5
- data/.github/dependabot.yml +12 -0
- data/.github/workflows/gempush.yml +29 -0
- data/.github/workflows/ruby.yaml +35 -0
- data/.gitignore +26 -26
- data/.rspec +2 -0
- data/.travis.yml +12 -20
- data/.yardopts +3 -0
- data/CHANGELOG.md +30 -25
- data/Gemfile +4 -4
- data/Guardfile +22 -26
- data/LICENSE +201 -28
- data/README.md +75 -100
- data/Rakefile +14 -11
- data/Vagrantfile +16 -16
- data/bin/puppet-moddeps +5 -5
- data/lib/puppet/moddeps.rb +8 -8
- data/lib/puppet/moddeps/installer.rb +244 -0
- data/lib/puppet/moddeps/module.rb +87 -0
- data/lib/puppet/moddeps/version.rb +5 -5
- data/puppet-moddeps.gemspec +50 -49
- data/spec/puppet/moddeps/installer_spec.rb +122 -0
- data/spec/spec_helper.rb +13 -16
- metadata +99 -52
- data/.coveralls.yml +0 -2
- data/lib/puppet/moddeps/install_deps.rb +0 -103
- data/scripts/vagrant-user.sh +0 -12
- data/spec/install_deps_spec.rb +0 -169
data/.coveralls.yml
DELETED
@@ -1,103 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'json'
|
3
|
-
require 'rbconfig'
|
4
|
-
|
5
|
-
module Puppet
|
6
|
-
module Moddeps
|
7
|
-
class InstallDeps
|
8
|
-
|
9
|
-
attr_reader :module_path, :deps
|
10
|
-
|
11
|
-
def initialize(path=nil, deps=nil)
|
12
|
-
if path and path.is_a?(String)
|
13
|
-
@module_path = path
|
14
|
-
elsif path
|
15
|
-
abort('The provided path was not a string.')
|
16
|
-
else
|
17
|
-
separator = self.path_separator(RbConfig::CONFIG['host_os'])
|
18
|
-
@module_path = %x(puppet config print modulepath).split(separator)[0]
|
19
|
-
end
|
20
|
-
|
21
|
-
if deps and deps.is_a?(Array)
|
22
|
-
@deps = deps
|
23
|
-
elsif deps
|
24
|
-
abort('The provided dependency list was not an array.')
|
25
|
-
else
|
26
|
-
@deps = []
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
def install(*puppet_module)
|
31
|
-
|
32
|
-
if puppet_module.size >=1 and puppet_module[0].is_a?(Array)
|
33
|
-
args = puppet_module[0]
|
34
|
-
else
|
35
|
-
args = puppet_module
|
36
|
-
end
|
37
|
-
|
38
|
-
if args.size == 1
|
39
|
-
if installed?(args[0])
|
40
|
-
self.parse_metadata(args[0])
|
41
|
-
self.install_modules
|
42
|
-
else
|
43
|
-
puts "Can't find #{args[0]} in #{@module_path}"
|
44
|
-
end
|
45
|
-
else
|
46
|
-
self.help
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
def help
|
51
|
-
puts 'Usage: puppet-moddeps module'
|
52
|
-
puts ' Call puppet-moddeps with the name of one installed module'
|
53
|
-
end
|
54
|
-
|
55
|
-
def installed?(module_name)
|
56
|
-
File.directory?("#{@module_path}/#{module_name}")
|
57
|
-
end
|
58
|
-
|
59
|
-
def path_separator(os_string)
|
60
|
-
if (/cygwin|mswin|mingw|bccwin|wince|emx/ =~ os_string) != nil
|
61
|
-
separator = ';'
|
62
|
-
else
|
63
|
-
separator = ':'
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
def parse_metadata(module_name)
|
68
|
-
metadata = File.read("#{@module_path}/#{module_name}/metadata.json")
|
69
|
-
data = JSON.parse(metadata)
|
70
|
-
self.parse_deps(data)
|
71
|
-
end
|
72
|
-
|
73
|
-
def parse_deps(data)
|
74
|
-
@deps.clear
|
75
|
-
|
76
|
-
data['dependencies'].each do |dep|
|
77
|
-
depname = dep["name"].sub '/', '-'
|
78
|
-
@deps.push( depname )
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
def install_modules
|
83
|
-
if @deps.size > 0
|
84
|
-
|
85
|
-
puts "Modules will be installed into #{module_path}"
|
86
|
-
|
87
|
-
@deps.each do |dep|
|
88
|
-
if self.installed?(dep)
|
89
|
-
puts "#{dep} is already installed, skipping."
|
90
|
-
else
|
91
|
-
cmd = "puppet module install #{dep}"
|
92
|
-
puts "Running \"#{cmd}\"..."
|
93
|
-
%x(#{cmd})
|
94
|
-
end
|
95
|
-
end
|
96
|
-
else
|
97
|
-
puts 'No dependencies were marked for installation.'
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end
|
data/scripts/vagrant-user.sh
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
#!/bin/bash
|
2
|
-
|
3
|
-
## This script should be executed as the vagrant user
|
4
|
-
|
5
|
-
if [ -f '/vagrant/GitConfig' ]; then
|
6
|
-
cp /vagrant/GitConfig ~/.gitconfig
|
7
|
-
fi
|
8
|
-
|
9
|
-
# Setup project
|
10
|
-
gem install bundler --no-ri --no-rdoc
|
11
|
-
cd puppet-moddeps
|
12
|
-
bundle install --jobs=3 --retry=3
|
data/spec/install_deps_spec.rb
DELETED
@@ -1,169 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Puppet::Moddeps::InstallDeps do
|
4
|
-
|
5
|
-
before(:all) do
|
6
|
-
puts 'Downloading the puppetlabs-apache module...'
|
7
|
-
|
8
|
-
%x(puppet module install puppetlabs-apache --ignore-dependencies)
|
9
|
-
|
10
|
-
@dirs_to_clean = ['apache']
|
11
|
-
|
12
|
-
if (/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RbConfig::CONFIG['host_os']) != nil
|
13
|
-
@expected_path = %x(puppet config print modulepath).split(';')[0]
|
14
|
-
else
|
15
|
-
@expected_path = %x(puppet config print modulepath).split(':')[0]
|
16
|
-
end
|
17
|
-
|
18
|
-
puts "The expected module path is: #{@expected_path}"
|
19
|
-
end
|
20
|
-
|
21
|
-
describe '.initialize(path, deps)' do
|
22
|
-
|
23
|
-
it 'should set the default module path and deps list' do
|
24
|
-
base_obj = Puppet::Moddeps::InstallDeps.new
|
25
|
-
|
26
|
-
expect(base_obj.module_path).to eq(@expected_path)
|
27
|
-
expect(base_obj.deps).to match_array []
|
28
|
-
end
|
29
|
-
|
30
|
-
it 'should use the provided values' do
|
31
|
-
base_obj = Puppet::Moddeps::InstallDeps.new('/tmp', ['dep1', 'dep2'])
|
32
|
-
expect(base_obj.module_path).to eq('/tmp')
|
33
|
-
expect(base_obj.deps).to contain_exactly('dep1', 'dep2')
|
34
|
-
end
|
35
|
-
|
36
|
-
it 'should fail when an array is passed to path' do
|
37
|
-
expect { Puppet::Moddeps::InstallDeps.new(['dep1', 'dep2']) }.to raise_error(SystemExit, 'The provided path was not a string.' )
|
38
|
-
end
|
39
|
-
|
40
|
-
it 'should fail when an string is passed to deps' do
|
41
|
-
expect { Puppet::Moddeps::InstallDeps.new('arg1', 'arg2') }.to raise_error(SystemExit, 'The provided dependency list was not an array.' )
|
42
|
-
end
|
43
|
-
|
44
|
-
end
|
45
|
-
|
46
|
-
describe '.install(puppet_module) feedback verification' do
|
47
|
-
|
48
|
-
before(:each) do
|
49
|
-
@base_object = Puppet::Moddeps::InstallDeps.new
|
50
|
-
end
|
51
|
-
|
52
|
-
context 'with no parameters' do
|
53
|
-
it 'should print usage info' do
|
54
|
-
expect { @base_object.install }.to output(/Usage.*/).to_stdout
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
context 'with two or more parameters' do
|
59
|
-
it 'should print usage info' do
|
60
|
-
expect { @base_object.install('arg1', 'arg2') }.to output(/Usage.*/).to_stdout
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
context 'with one parameter' do
|
65
|
-
it 'should print usage if multiple arguments come in as an array' do
|
66
|
-
params = ['arg1', 'arg2']
|
67
|
-
expect { @base_object.install(params) }.to output(/Usage.*/).to_stdout
|
68
|
-
end
|
69
|
-
|
70
|
-
it 'should print usage if an empty array is passed in' do
|
71
|
-
params = []
|
72
|
-
expect { @base_object.install(params) }.to output(/Usage.*/).to_stdout
|
73
|
-
end
|
74
|
-
|
75
|
-
it 'should fail if the parameter is not an installed module' do
|
76
|
-
expect { @base_object.install('fake_missing_module') }.to output(/Can\'t find fake_missing_module in.*/).to_stdout
|
77
|
-
end
|
78
|
-
|
79
|
-
end
|
80
|
-
|
81
|
-
end
|
82
|
-
|
83
|
-
describe '.path_separator' do
|
84
|
-
|
85
|
-
subject { Puppet::Moddeps::InstallDeps.new }
|
86
|
-
|
87
|
-
context 'on Windows' do
|
88
|
-
it 'should return ; as the path separator' do
|
89
|
-
expect(subject.path_separator('mingw32')).to eq(';')
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
context 'on Linux' do
|
94
|
-
it 'should return : as the path separator' do
|
95
|
-
expect(subject.path_separator('linux-gnu')).to eq(':')
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
describe '.parse_metadata' do
|
101
|
-
|
102
|
-
it "should parse metadata.json" do
|
103
|
-
base_object = Puppet::Moddeps::InstallDeps.new
|
104
|
-
|
105
|
-
base_object.parse_metadata('apache')
|
106
|
-
|
107
|
-
expect(base_object.deps).to contain_exactly('puppetlabs-stdlib', 'puppetlabs-concat')
|
108
|
-
end
|
109
|
-
|
110
|
-
end
|
111
|
-
|
112
|
-
describe '.install_modules' do
|
113
|
-
|
114
|
-
before(:all) do
|
115
|
-
@base_object = Puppet::Moddeps::InstallDeps.new
|
116
|
-
end
|
117
|
-
|
118
|
-
it 'should say the module is already installed' do
|
119
|
-
@base_object.instance_variable_set(:@deps, ['apache'])
|
120
|
-
|
121
|
-
expect { @base_object.install_modules }.to output(/apache is already installed.*/).to_stdout
|
122
|
-
end
|
123
|
-
|
124
|
-
it 'should say nothing to install' do
|
125
|
-
@base_object.instance_variable_set(:@deps, [])
|
126
|
-
|
127
|
-
expect { @base_object.install_modules }.to output(/No dependencies were marked for installation.*/).to_stdout
|
128
|
-
end
|
129
|
-
|
130
|
-
end
|
131
|
-
|
132
|
-
describe '.install actual Puppet modules' do
|
133
|
-
|
134
|
-
it "should install each module in provided array" do
|
135
|
-
base_object = Puppet::Moddeps::InstallDeps.new
|
136
|
-
|
137
|
-
base_object.install('apache')
|
138
|
-
|
139
|
-
basedir = base_object.module_path
|
140
|
-
|
141
|
-
base_object.deps.each do |dep|
|
142
|
-
mod_dir = dep.split('-')[1]
|
143
|
-
@dirs_to_clean.push(mod_dir)
|
144
|
-
|
145
|
-
mod_path = "#{basedir}/#{mod_dir}"
|
146
|
-
expect(File.directory?(mod_path)).to eql(true)
|
147
|
-
end
|
148
|
-
|
149
|
-
end
|
150
|
-
|
151
|
-
end
|
152
|
-
|
153
|
-
after(:all) do
|
154
|
-
|
155
|
-
@dirs_to_clean.each do |mod_dir|
|
156
|
-
path_to_clean = @expected_path + "/#{mod_dir}"
|
157
|
-
|
158
|
-
if (/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RbConfig::CONFIG['host_os']) != nil
|
159
|
-
puts "Removing #{path_to_clean.gsub '/', '\\'}"
|
160
|
-
%x(rmdir /Q /S #{path_to_clean.gsub '/', '\\'})
|
161
|
-
else
|
162
|
-
puts "Removing #{path_to_clean}"
|
163
|
-
%x(rm -rf #{path_to_clean})
|
164
|
-
end
|
165
|
-
|
166
|
-
end
|
167
|
-
end
|
168
|
-
|
169
|
-
end
|