chef-sugar 4.2.1 → 5.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 +4 -4
- data/lib/chef/sugar/version.rb +1 -1
- metadata +3 -63
- data/.github/lock.yml +0 -3
- data/.github/reaction.yml +0 -1
- data/.gitignore +0 -26
- data/.kitchen.yml +0 -16
- data/.travis.yml +0 -17
- data/CHANGELOG.md +0 -261
- data/CONTRIBUTING.md +0 -20
- data/Gemfile +0 -2
- data/README.md +0 -540
- data/Rakefile +0 -11
- data/chef-sugar.gemspec +0 -33
- data/libraries/chef-sugar.rb +0 -1
- data/metadata.rb +0 -24
- data/recipes/default.rb +0 -20
- data/spec/spec_helper.rb +0 -25
- data/spec/support/shared_examples.rb +0 -20
- data/spec/unit/chef/sugar/architecture_spec.rb +0 -129
- data/spec/unit/chef/sugar/cloud_spec.rb +0 -149
- data/spec/unit/chef/sugar/constraints_spec.rb +0 -45
- data/spec/unit/chef/sugar/core_extensions/array_spec.rb +0 -10
- data/spec/unit/chef/sugar/core_extensions/object_spec.rb +0 -62
- data/spec/unit/chef/sugar/core_extensions/string_spec.rb +0 -48
- data/spec/unit/chef/sugar/data_bag_spec.rb +0 -118
- data/spec/unit/chef/sugar/docker_spec.rb +0 -39
- data/spec/unit/chef/sugar/init_spec.rb +0 -74
- data/spec/unit/chef/sugar/ip_spec.rb +0 -53
- data/spec/unit/chef/sugar/kernel_spec.rb +0 -16
- data/spec/unit/chef/sugar/kitchen_spec.rb +0 -18
- data/spec/unit/chef/sugar/node_spec.rb +0 -172
- data/spec/unit/chef/sugar/platform_family_spec.rb +0 -166
- data/spec/unit/chef/sugar/platform_spec.rb +0 -342
- data/spec/unit/chef/sugar/ruby_spec.rb +0 -39
- data/spec/unit/chef/sugar/run_context_spec.rb +0 -19
- data/spec/unit/chef/sugar/shell_spec.rb +0 -104
- data/spec/unit/chef/sugar/vagrant_spec.rb +0 -37
- data/spec/unit/chef/sugar/virtualization_spec.rb +0 -135
- data/spec/unit/recipes/default_spec.rb +0 -9
@@ -1,39 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Chef::Sugar::Ruby do
|
4
|
-
it_behaves_like 'a chef sugar'
|
5
|
-
|
6
|
-
describe '#ruby_20?' do
|
7
|
-
it 'returns true when the ruby version is 2.0' do
|
8
|
-
node = { 'languages' => { 'ruby' => { 'version' => '2.0.0' } } }
|
9
|
-
expect(described_class.ruby_20?(node)).to be true
|
10
|
-
end
|
11
|
-
|
12
|
-
it 'returns true when the ruby version is less than 2.0' do
|
13
|
-
node = { 'languages' => { 'ruby' => { 'version' => '1.9.3' } } }
|
14
|
-
expect(described_class.ruby_20?(node)).to be false
|
15
|
-
end
|
16
|
-
|
17
|
-
it 'returns false when the ruby version is higher than 2.0' do
|
18
|
-
node = { 'languages' => { 'ruby' => { 'version' => '3.0.0' } } }
|
19
|
-
expect(described_class.ruby_20?(node)).to be false
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
describe '#ruby_19?' do
|
24
|
-
it 'returns true when the ruby version is 1.9' do
|
25
|
-
node = { 'languages' => { 'ruby' => { 'version' => '1.9.1' } } }
|
26
|
-
expect(described_class.ruby_19?(node)).to be true
|
27
|
-
end
|
28
|
-
|
29
|
-
it 'returns true when the ruby version is less than 1.9' do
|
30
|
-
node = { 'languages' => { 'ruby' => { 'version' => '1.8.7' } } }
|
31
|
-
expect(described_class.ruby_19?(node)).to be false
|
32
|
-
end
|
33
|
-
|
34
|
-
it 'returns false when the ruby version is higher than 1.9' do
|
35
|
-
node = { 'languages' => { 'ruby' => { 'version' => '2.0.0' } } }
|
36
|
-
expect(described_class.ruby_19?(node)).to be false
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Chef::Sugar::RunContext do
|
4
|
-
it_behaves_like 'a chef sugar'
|
5
|
-
|
6
|
-
describe '#includes_recipe?' do
|
7
|
-
let(:node) { double(Chef::Node) }
|
8
|
-
|
9
|
-
it 'returns true when the recipe exists' do
|
10
|
-
allow(node).to receive(:recipe?).and_return(true)
|
11
|
-
expect(described_class.includes_recipe?(node, 'foo')).to be true
|
12
|
-
end
|
13
|
-
|
14
|
-
it 'returns false when the recipe does not exist' do
|
15
|
-
allow(node).to receive(:recipe?).and_return(false)
|
16
|
-
expect(described_class.includes_recipe?(node, 'bar')).to be false
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
@@ -1,104 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Chef::Sugar::Shell do
|
4
|
-
describe '#which' do
|
5
|
-
it 'returns the first executable matching the command' do
|
6
|
-
allow(File).to receive(:executable?).and_return(false)
|
7
|
-
allow(File).to receive(:executable?).with('/usr/bin/mongo').and_return(true)
|
8
|
-
expect(described_class.which('mongo')).to eq('/usr/bin/mongo')
|
9
|
-
end
|
10
|
-
|
11
|
-
it 'returns nil when no command is found' do
|
12
|
-
allow(File).to receive(:executable?).and_return(false)
|
13
|
-
expect(described_class.which('node')).to be_nil
|
14
|
-
end
|
15
|
-
|
16
|
-
context 'with an absolute path' do
|
17
|
-
it 'returns the executable if it exists' do
|
18
|
-
allow(File).to receive(:executable?).with('/usr/local/bin/bash').and_return(true)
|
19
|
-
expect(described_class.which('/usr/local/bin/bash')).to eq('/usr/local/bin/bash')
|
20
|
-
end
|
21
|
-
|
22
|
-
it 'returns nil when the file is not executable' do
|
23
|
-
allow(File).to receive(:executable?).with('/usr/local/bin/bash').and_return(false)
|
24
|
-
expect(described_class.which('/usr/local/bin/bash')).to be_nil
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
describe '#dev_null' do
|
30
|
-
it 'returns NUL on Windows' do
|
31
|
-
node = { 'platform_family' => 'windows' }
|
32
|
-
expect(described_class.dev_null(node)).to eq('NUL')
|
33
|
-
end
|
34
|
-
|
35
|
-
it 'returns /dev/null on Linux' do
|
36
|
-
node = { 'platform_family' => 'debian' }
|
37
|
-
expect(described_class.dev_null(node)).to eq('/dev/null')
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
describe '#installed?' do
|
42
|
-
it 'returns true if the given binary exists' do
|
43
|
-
allow(described_class).to receive(:which).and_return(nil)
|
44
|
-
allow(described_class).to receive(:which).with('mongo').and_return(true)
|
45
|
-
expect(described_class.installed?('mongo')).to be true
|
46
|
-
end
|
47
|
-
|
48
|
-
it 'returns false if the given binary does not exist' do
|
49
|
-
allow(File).to receive(:executable?).and_return(false)
|
50
|
-
expect(described_class.installed?('node')).to be false
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
describe '#installed_at_version?' do
|
55
|
-
it 'returns true if the command is installed at the correct version' do
|
56
|
-
allow(described_class).to receive(:which).and_return(true)
|
57
|
-
allow(described_class).to receive(:version_for).and_return('1.2.3')
|
58
|
-
expect(described_class.installed_at_version?('mongo', '1.2.3')).to be true
|
59
|
-
end
|
60
|
-
|
61
|
-
it 'returns true if the command is installed at the correct version and has additional output' do
|
62
|
-
allow(described_class).to receive(:which).and_return(true)
|
63
|
-
allow(described_class).to receive(:version_for).and_return('Mongo DB version 1.2.3. Some other text.')
|
64
|
-
expect(described_class.installed_at_version?('mongo', '1.2.3')).to be true
|
65
|
-
end
|
66
|
-
|
67
|
-
it 'returns true if the command is installed at the correct version with a regex' do
|
68
|
-
allow(described_class).to receive(:which).and_return(true)
|
69
|
-
allow(described_class).to receive(:version_for).and_return('1.2.3')
|
70
|
-
expect(described_class.installed_at_version?('mongo', /1\.2/)).to be true
|
71
|
-
end
|
72
|
-
|
73
|
-
it 'returns false if the command is installed at the wrong version' do
|
74
|
-
allow(described_class).to receive(:which).and_return(true)
|
75
|
-
allow(described_class).to receive(:version_for).and_return('1.2.3')
|
76
|
-
expect(described_class.installed_at_version?('mongo', '4.5.6')).to be false
|
77
|
-
end
|
78
|
-
|
79
|
-
it 'returns false if #version_for is nil' do
|
80
|
-
allow(described_class).to receive(:which).and_return(true)
|
81
|
-
allow(described_class).to receive(:version_for).and_return(nil)
|
82
|
-
expect(described_class.installed_at_version?('mongo', '4.5.6')).to be false
|
83
|
-
end
|
84
|
-
|
85
|
-
it 'returns false if the command is not installed' do
|
86
|
-
allow(described_class).to receive(:which).and_return(nil)
|
87
|
-
expect(described_class.installed_at_version?('mongo', '1.0.0')).to be false
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
describe '#version_for' do
|
92
|
-
let(:shell_out) { double('shell_out', run_command: nil, error!: nil, stdout: '1.2.3', stderr: 'Oh no!') }
|
93
|
-
before { allow(Mixlib::ShellOut).to receive(:new).and_return(shell_out) }
|
94
|
-
|
95
|
-
it 'runs the thing in shellout' do
|
96
|
-
expect(Mixlib::ShellOut).to receive(:new).with('mongo --version')
|
97
|
-
described_class.version_for('mongo')
|
98
|
-
end
|
99
|
-
|
100
|
-
it 'returns the combined stdout and stderr' do
|
101
|
-
expect(described_class.version_for('mongo')).to eq("1.2.3\nOh no!")
|
102
|
-
end
|
103
|
-
end
|
104
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Chef::Sugar::Vagrant do
|
4
|
-
it_behaves_like 'a chef sugar'
|
5
|
-
|
6
|
-
describe '#vagrant?' do
|
7
|
-
it 'returns true when the machine is on vagrant' do
|
8
|
-
node = { 'vagrant' => {} }
|
9
|
-
expect(described_class.vagrant?(node)).to be true
|
10
|
-
end
|
11
|
-
|
12
|
-
it 'returns true when the domain is vagrantup.com' do
|
13
|
-
node = { 'domain' => 'bacon.vagrantup.com' }
|
14
|
-
expect(described_class.vagrant?(node)).to be true
|
15
|
-
end
|
16
|
-
|
17
|
-
it 'returns false when the domain is nil' do
|
18
|
-
node = { 'domain' => nil }
|
19
|
-
expect(described_class.vagrant?(node)).to be false
|
20
|
-
end
|
21
|
-
|
22
|
-
it 'returns false when the domain is not vagrantup.com' do
|
23
|
-
node = { 'domain' => 'sethvargo.com' }
|
24
|
-
expect(described_class.vagrant?(node)).to be false
|
25
|
-
end
|
26
|
-
|
27
|
-
it 'returns true when the vagrant user exists on the system' do
|
28
|
-
node = { 'etc' => { 'passwd' => { 'vagrant' => {} } } }
|
29
|
-
expect(described_class.vagrant?(node)).to be true
|
30
|
-
end
|
31
|
-
|
32
|
-
it 'returns false when the machine is not on vagrant' do
|
33
|
-
node = {}
|
34
|
-
expect(described_class.vagrant?(node)).to be false
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
@@ -1,135 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Chef::Sugar::Virtualization do
|
4
|
-
it_behaves_like 'a chef sugar'
|
5
|
-
|
6
|
-
describe '#kvm?' do
|
7
|
-
it 'returns true when the machine is under kvm' do
|
8
|
-
node = { 'virtualization' => { 'system' => 'kvm' } }
|
9
|
-
expect(described_class.kvm?(node)).to be true
|
10
|
-
end
|
11
|
-
|
12
|
-
it 'returns false when the virtual machine is not under kvm' do
|
13
|
-
node = { 'virtualization' => { 'system' => 'vbox' } }
|
14
|
-
expect(described_class.kvm?(node)).to be false
|
15
|
-
end
|
16
|
-
|
17
|
-
it 'returns false when the machine is not virtual' do
|
18
|
-
node = {}
|
19
|
-
expect(described_class.kvm?(node)).to be false
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
describe '#lxc?' do
|
24
|
-
it 'returns true when the machine is a linux contianer' do
|
25
|
-
node = { 'virtualization' => { 'system' => 'lxc' } }
|
26
|
-
expect(described_class.lxc?(node)).to be true
|
27
|
-
end
|
28
|
-
|
29
|
-
it 'returns false when the virtual machine is not lxc' do
|
30
|
-
node = { 'virtualization' => { 'system' => 'vbox' } }
|
31
|
-
expect(described_class.lxc?(node)).to be false
|
32
|
-
end
|
33
|
-
|
34
|
-
it 'returns false when the machine is not virtual' do
|
35
|
-
node = {}
|
36
|
-
expect(described_class.lxc?(node)).to be false
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
describe '#parallels?' do
|
41
|
-
it 'returns true when the machine is under parallels' do
|
42
|
-
node = { 'virtualization' => { 'system' => 'Parallels' } }
|
43
|
-
expect(described_class.parallels?(node)).to be true
|
44
|
-
end
|
45
|
-
|
46
|
-
it 'returns false when the virtual machine is not under parallels' do
|
47
|
-
node = { 'virtualization' => { 'system' => 'kvm' } }
|
48
|
-
expect(described_class.parallels?(node)).to be false
|
49
|
-
end
|
50
|
-
|
51
|
-
it 'returns false when the machine is not virtual' do
|
52
|
-
node = {}
|
53
|
-
expect(described_class.parallels?(node)).to be false
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
describe '#virtualbox?' do
|
58
|
-
it 'returns true when the machine is under virtualbox' do
|
59
|
-
node = { 'virtualization' => { 'system' => 'vbox' } }
|
60
|
-
expect(described_class.virtualbox?(node)).to be true
|
61
|
-
end
|
62
|
-
|
63
|
-
it 'returns false when the virtual machine is not under virtualbox' do
|
64
|
-
node = { 'virtualization' => { 'system' => 'kvm' } }
|
65
|
-
expect(described_class.virtualbox?(node)).to be false
|
66
|
-
end
|
67
|
-
|
68
|
-
it 'returns false when the machine is not virtual' do
|
69
|
-
node = {}
|
70
|
-
expect(described_class.virtualbox?(node)).to be false
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
describe '#vmware?' do
|
75
|
-
it 'returns true when the machine is under vmware' do
|
76
|
-
node = { 'virtualization' => { 'system' => 'vmware' } }
|
77
|
-
expect(described_class.vmware?(node)).to be true
|
78
|
-
end
|
79
|
-
|
80
|
-
it 'returns false when the virtual machine is not under vmware' do
|
81
|
-
node = { 'virtualization' => { 'system' => 'vbox' } }
|
82
|
-
expect(described_class.vmware?(node)).to be false
|
83
|
-
end
|
84
|
-
|
85
|
-
it 'returns false when the machine is not virtual' do
|
86
|
-
node = {}
|
87
|
-
expect(described_class.vmware?(node)).to be false
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
describe '#openvz?' do
|
92
|
-
it 'returns true when the machine is under openvz' do
|
93
|
-
node = { 'virtualization' => { 'system' => 'openvz' } }
|
94
|
-
expect(described_class.openvz?(node)).to be true
|
95
|
-
end
|
96
|
-
|
97
|
-
it 'returns false when the virtual machine is not under openvz' do
|
98
|
-
node = { 'virtualization' => { 'system' => 'kvm' } }
|
99
|
-
expect(described_class.openvz?(node)).to be false
|
100
|
-
end
|
101
|
-
|
102
|
-
it 'returns false when the machine is not virtual' do
|
103
|
-
node = {}
|
104
|
-
expect(described_class.openvz?(node)).to be false
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
describe '#virtual?' do
|
109
|
-
it 'returns true when the machine is under a supported virtualization provider' do
|
110
|
-
%w(openvz vmware vbox lxc kvm).each do |host|
|
111
|
-
node = { 'virtualization' => { 'system' => host } }
|
112
|
-
expect(described_class.virtual?(node)).to be true
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
|
-
it 'returns false when the machine is not virtual' do
|
117
|
-
node = {}
|
118
|
-
expect(described_class.virtual?(node)).to be false
|
119
|
-
end
|
120
|
-
end
|
121
|
-
|
122
|
-
describe '#physical?' do
|
123
|
-
it 'returns false when the machine is under a supported virtualization provider' do
|
124
|
-
%w(openvz vmware vbox lxc kvm).each do |host|
|
125
|
-
node = { 'virtualization' => { 'system' => host } }
|
126
|
-
expect(described_class.physical?(node)).to be false
|
127
|
-
end
|
128
|
-
end
|
129
|
-
|
130
|
-
it 'returns true when the machine is not virtual' do
|
131
|
-
node = {}
|
132
|
-
expect(described_class.physical?(node)).to be true
|
133
|
-
end
|
134
|
-
end
|
135
|
-
end
|