vanagon 0.3.18

Sign up to get free protection for your applications and to get access to all the features.
Files changed (80) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +13 -0
  3. data/README.md +175 -0
  4. data/bin/build +33 -0
  5. data/bin/devkit +22 -0
  6. data/bin/repo +26 -0
  7. data/bin/ship +15 -0
  8. data/lib/vanagon.rb +8 -0
  9. data/lib/vanagon/common.rb +2 -0
  10. data/lib/vanagon/common/pathname.rb +87 -0
  11. data/lib/vanagon/common/user.rb +25 -0
  12. data/lib/vanagon/component.rb +157 -0
  13. data/lib/vanagon/component/dsl.rb +307 -0
  14. data/lib/vanagon/component/source.rb +66 -0
  15. data/lib/vanagon/component/source/git.rb +60 -0
  16. data/lib/vanagon/component/source/http.rb +158 -0
  17. data/lib/vanagon/driver.rb +112 -0
  18. data/lib/vanagon/engine/base.rb +82 -0
  19. data/lib/vanagon/engine/docker.rb +40 -0
  20. data/lib/vanagon/engine/local.rb +40 -0
  21. data/lib/vanagon/engine/pooler.rb +85 -0
  22. data/lib/vanagon/errors.rb +28 -0
  23. data/lib/vanagon/extensions/string.rb +11 -0
  24. data/lib/vanagon/optparse.rb +62 -0
  25. data/lib/vanagon/platform.rb +245 -0
  26. data/lib/vanagon/platform/deb.rb +71 -0
  27. data/lib/vanagon/platform/dsl.rb +293 -0
  28. data/lib/vanagon/platform/osx.rb +100 -0
  29. data/lib/vanagon/platform/rpm.rb +76 -0
  30. data/lib/vanagon/platform/rpm/wrl.rb +39 -0
  31. data/lib/vanagon/platform/solaris_10.rb +182 -0
  32. data/lib/vanagon/platform/solaris_11.rb +138 -0
  33. data/lib/vanagon/platform/swix.rb +35 -0
  34. data/lib/vanagon/project.rb +251 -0
  35. data/lib/vanagon/project/dsl.rb +218 -0
  36. data/lib/vanagon/utilities.rb +299 -0
  37. data/spec/fixures/component/invalid-test-fixture.json +3 -0
  38. data/spec/fixures/component/mcollective.service +1 -0
  39. data/spec/fixures/component/test-fixture.json +4 -0
  40. data/spec/lib/vanagon/common/pathname_spec.rb +103 -0
  41. data/spec/lib/vanagon/common/user_spec.rb +36 -0
  42. data/spec/lib/vanagon/component/dsl_spec.rb +443 -0
  43. data/spec/lib/vanagon/component/source/git_spec.rb +19 -0
  44. data/spec/lib/vanagon/component/source/http_spec.rb +43 -0
  45. data/spec/lib/vanagon/component/source_spec.rb +99 -0
  46. data/spec/lib/vanagon/component_spec.rb +22 -0
  47. data/spec/lib/vanagon/engine/base_spec.rb +40 -0
  48. data/spec/lib/vanagon/engine/docker_spec.rb +40 -0
  49. data/spec/lib/vanagon/engine/pooler_spec.rb +54 -0
  50. data/spec/lib/vanagon/platform/deb_spec.rb +60 -0
  51. data/spec/lib/vanagon/platform/dsl_spec.rb +128 -0
  52. data/spec/lib/vanagon/platform/rpm_spec.rb +41 -0
  53. data/spec/lib/vanagon/platform/solaris_11_spec.rb +44 -0
  54. data/spec/lib/vanagon/platform_spec.rb +53 -0
  55. data/spec/lib/vanagon/project/dsl_spec.rb +203 -0
  56. data/spec/lib/vanagon/project_spec.rb +44 -0
  57. data/spec/lib/vanagon/utilities_spec.rb +140 -0
  58. data/templates/Makefile.erb +116 -0
  59. data/templates/deb/changelog.erb +5 -0
  60. data/templates/deb/conffiles.erb +3 -0
  61. data/templates/deb/control.erb +21 -0
  62. data/templates/deb/dirs.erb +3 -0
  63. data/templates/deb/docs.erb +1 -0
  64. data/templates/deb/install.erb +3 -0
  65. data/templates/deb/postinst.erb +46 -0
  66. data/templates/deb/postrm.erb +15 -0
  67. data/templates/deb/prerm.erb +17 -0
  68. data/templates/deb/rules.erb +25 -0
  69. data/templates/osx/postinstall.erb +24 -0
  70. data/templates/osx/preinstall.erb +19 -0
  71. data/templates/osx/project-installer.xml.erb +19 -0
  72. data/templates/rpm/project.spec.erb +217 -0
  73. data/templates/solaris/10/depend.erb +3 -0
  74. data/templates/solaris/10/pkginfo.erb +13 -0
  75. data/templates/solaris/10/postinstall.erb +37 -0
  76. data/templates/solaris/10/preinstall.erb +7 -0
  77. data/templates/solaris/10/preremove.erb +6 -0
  78. data/templates/solaris/10/proto.erb +5 -0
  79. data/templates/solaris/11/p5m.erb +73 -0
  80. metadata +172 -0
@@ -0,0 +1,43 @@
1
+ require 'vanagon/component/source/git'
2
+
3
+ describe "Vanagon::Component::Source::Http" do
4
+ let (:base_url) { 'http://buildsources.delivery.puppetlabs.net' }
5
+ let (:file_base) { 'thing-1.2.3' }
6
+ let (:tar_filename) { 'thing-1.2.3.tar.gz' }
7
+ let (:tar_url) { "#{base_url}/#{tar_filename}" }
8
+ let (:tar_dirname) { 'thing-1.2.3' }
9
+ let (:plaintext_filename) { 'thing-1.2.3.txt' }
10
+ let (:plaintext_url) { "#{base_url}/#{plaintext_filename}" }
11
+ let (:plaintext_dirname) { './' }
12
+ let (:md5sum) { 'abcdssasasa' }
13
+ let (:workdir) { "/tmp" }
14
+
15
+ describe "#dirname" do
16
+ it "returns the name of the tarball, minus extension for archives" do
17
+ http_source = Vanagon::Component::Source::Http.new(tar_url, md5sum, workdir)
18
+ expect(http_source).to receive(:download).and_return(tar_filename)
19
+ http_source.fetch
20
+ expect(http_source.dirname).to eq(tar_dirname)
21
+ end
22
+
23
+ it "returns the current directory for non-archive files" do
24
+ http_source = Vanagon::Component::Source::Http.new(plaintext_url, md5sum, workdir)
25
+ expect(http_source).to receive(:download).and_return(plaintext_filename)
26
+ http_source.fetch
27
+ expect(http_source.dirname).to eq(plaintext_dirname)
28
+ end
29
+ end
30
+
31
+ describe "#get_extension" do
32
+ it "returns the extension for valid extensions" do
33
+ (Vanagon::Component::Source::Http::ARCHIVE_EXTENSIONS + Vanagon::Component::Source::Http::NON_ARCHIVE_EXTENSIONS).each do |ext|
34
+ filename = "#{file_base}#{ext}"
35
+ url = File.join(base_url, filename)
36
+ http_source = Vanagon::Component::Source::Http.new(url, md5sum, workdir)
37
+ expect(http_source).to receive(:download).and_return(filename)
38
+ http_source.fetch
39
+ expect(http_source.get_extension).to eq(ext)
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,99 @@
1
+ require 'vanagon/component/source'
2
+
3
+ describe "Vanagon::Component::Source" do
4
+ before(:each) do
5
+ Vanagon::Component::Source.class_variable_set(:@@rewrite_rule, {})
6
+ end
7
+
8
+ describe "self.source" do
9
+ let (:unrecognized_scheme) { "abcd://things" }
10
+ let (:invalid_scheme) { "abcd|things" }
11
+ let (:public_git) { "git://github.com/abcd/things" }
12
+ let (:private_git) { "git@github.com:abcd/things" }
13
+ let (:http_url) { "http://abcd/things" }
14
+ let (:https_url) { "https://abcd/things" }
15
+ let (:file_url) { "file://things" }
16
+
17
+ let (:ref) { "1.2.3" }
18
+ let (:sum) { "abcd1234" }
19
+ let (:workdir) { "/tmp" }
20
+
21
+ it "fails on unrecognized uri schemes" do
22
+ expect { Vanagon::Component::Source.source(unrecognized_scheme, {}, workdir) }.to raise_error(RuntimeError)
23
+ end
24
+
25
+ it "fails on invalid uris" do
26
+ expect { Vanagon::Component::Source.source(invalid_scheme, {}, workdir) }.to raise_error(RuntimeError)
27
+ end
28
+
29
+ it "returns an object of the correct type for git@ urls" do
30
+ expect(Vanagon::Component::Source.source(private_git, {:ref => ref }, workdir).class).to equal(Vanagon::Component::Source::Git)
31
+ end
32
+
33
+ it "returns an object of the correct type for git:// urls" do
34
+ expect(Vanagon::Component::Source.source(public_git, {:ref => ref }, workdir).class).to equal(Vanagon::Component::Source::Git)
35
+ end
36
+
37
+ it "returns an object of the correct type for http:// urls" do
38
+ expect(Vanagon::Component::Source.source(http_url, {:sum => sum }, workdir).class).to equal(Vanagon::Component::Source::Http)
39
+ end
40
+
41
+ it "returns an object of the correct type for https:// urls" do
42
+ expect(Vanagon::Component::Source.source(https_url, {:sum => sum }, workdir).class).to equal(Vanagon::Component::Source::Http)
43
+ end
44
+
45
+ it "returns an object of the correct type for file:// urls" do
46
+ expect(Vanagon::Component::Source.source(file_url, {:sum => sum }, workdir).class).to equal(Vanagon::Component::Source::Http)
47
+ end
48
+
49
+ it "applies any rewrite rules before defining an http Source" do
50
+ Vanagon::Component::Source.register_rewrite_rule('http', 'http://buildsources.delivery.puppetlabs.net')
51
+ expect(Vanagon::Component::Source.source('http://things.and.stuff/foo.tar.gz', {:sum => sum }, workdir).url).to eq('http://buildsources.delivery.puppetlabs.net/foo.tar.gz')
52
+ end
53
+
54
+ it "applies any rewrite rules before defining an http Source" do
55
+ Vanagon::Component::Source.register_rewrite_rule('git', Proc.new {|url| url.gsub('a', 'e') })
56
+ expect(Vanagon::Component::Source.source('git://things.and.stuff/foo-bar.git', {:ref => ref }, workdir).url).to eq('git://things.end.stuff/foo-ber.git')
57
+ end
58
+ end
59
+
60
+ describe "self.rewrite" do
61
+ let(:simple_rule) { Proc.new {|url| url.gsub('a', 'e') } }
62
+ let(:complex_rule) do
63
+ Proc.new { |url|
64
+ match = url.match(/github.com\/(.*)$/)
65
+ "git://github.delivery.puppetlabs.net/#{match[1].gsub('/', '-')}" if match
66
+ }
67
+ end
68
+
69
+ it 'replaces the first section of a url with a string if string is given' do
70
+ Vanagon::Component::Source.register_rewrite_rule('http', 'http://buildsources.delivery.puppetlabs.net')
71
+ expect(Vanagon::Component::Source.rewrite('http://things.and.stuff/foo.tar.gz', 'http')).to eq('http://buildsources.delivery.puppetlabs.net/foo.tar.gz')
72
+ end
73
+
74
+ it 'applies the rule to the url if a proc is given as the rule' do
75
+ Vanagon::Component::Source.register_rewrite_rule('http', simple_rule)
76
+ expect(Vanagon::Component::Source.rewrite('http://things.and.stuff/foo.tar.gz', 'http')).to eq('http://things.end.stuff/foo.ter.gz')
77
+ end
78
+
79
+ it 'applies the rule to the url if a proc is given as the rule' do
80
+ Vanagon::Component::Source.register_rewrite_rule('git', complex_rule)
81
+ expect(Vanagon::Component::Source.rewrite('git://github.com/puppetlabs/facter', 'git')).to eq('git://github.delivery.puppetlabs.net/puppetlabs-facter')
82
+ end
83
+ end
84
+
85
+ describe "self.register_rewrite_rule" do
86
+ it 'only accepts Proc and String as rule types' do
87
+ expect{Vanagon::Component::Source.register_rewrite_rule('http', 5)}.to raise_error(Vanagon::Error)
88
+ end
89
+
90
+ it 'rejects invalid protocols' do
91
+ expect{Vanagon::Component::Source.register_rewrite_rule('gopher', 'abcd')}.to raise_error(Vanagon::Error)
92
+ end
93
+
94
+ it 'registers the rule for the given protocol' do
95
+ Vanagon::Component::Source.register_rewrite_rule('http', 'http://buildsources.delivery.puppetlabs.net')
96
+ expect(Vanagon::Component::Source.class_variable_get(:@@rewrite_rule)).to eq({'http' => 'http://buildsources.delivery.puppetlabs.net'})
97
+ end
98
+ end
99
+ end
@@ -0,0 +1,22 @@
1
+ require 'vanagon/component'
2
+
3
+ describe "Vanagon::Component" do
4
+ describe "#get_environment" do
5
+ it "returns a makefile compatible environment" do
6
+ comp = Vanagon::Component.new('env-test', {}, {})
7
+ comp.environment = {'PATH' => '/usr/local/bin'}
8
+ expect(comp.get_environment).to eq('export PATH="/usr/local/bin"')
9
+ end
10
+
11
+ it 'merges against the existing environment' do
12
+ comp = Vanagon::Component.new('env-test', {}, {})
13
+ comp.environment = {'PATH' => '/usr/bin', 'CFLAGS' => '-I /usr/local/bin'}
14
+ expect(comp.get_environment).to eq('export PATH="/usr/bin" CFLAGS="-I /usr/local/bin"')
15
+ end
16
+
17
+ it 'returns : for an empty environment' do
18
+ comp = Vanagon::Component.new('env-test', {}, {})
19
+ expect(comp.get_environment).to eq(':')
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,40 @@
1
+ require 'vanagon/engine/base'
2
+
3
+ describe 'Vanagon::Engine::Base' do
4
+ let (:platform_without_ssh_port) {
5
+ plat = Vanagon::Platform::DSL.new('debian-6-i386')
6
+ plat.instance_eval("platform 'debian-6-i386' do |plat|
7
+ plat.ssh_port nil
8
+ end")
9
+ plat._platform
10
+ }
11
+
12
+ let (:platform) {
13
+ plat = Vanagon::Platform::DSL.new('debian-6-i386')
14
+ plat.instance_eval("platform 'debian-6-i386' do |plat|
15
+ end")
16
+ plat._platform
17
+ }
18
+
19
+ describe '#select_target' do
20
+ it 'raises an error without a target' do
21
+ base = Vanagon::Engine::Base.new(platform)
22
+ expect { base.select_target }.to raise_error(Vanagon::Error)
23
+ end
24
+
25
+ it 'returns a target if one is set' do
26
+ base = Vanagon::Engine::Base.new(platform, 'abcd')
27
+ expect(base.select_target).to eq('abcd')
28
+ end
29
+ end
30
+
31
+ describe '#validate_platform' do
32
+ it 'raises an error if the platform is missing a required attribute' do
33
+ expect{ Vanagon::Engine::Base.new(platform_without_ssh_port).validate_platform }.to raise_error(Vanagon::Error)
34
+ end
35
+
36
+ it 'returns true if the platform has the required attributes' do
37
+ expect(Vanagon::Engine::Base.new(platform).validate_platform).to be(true)
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,40 @@
1
+ require 'vanagon/engine/docker'
2
+
3
+ describe 'Vanagon::Engine::Docker' do
4
+ let (:platform_with_docker_image) {
5
+ plat = Vanagon::Platform::DSL.new('debian-6-i386')
6
+ plat.instance_eval("platform 'debian-6-i386' do |plat|
7
+ plat.docker_image 'debian-6-i386'
8
+ end")
9
+ plat._platform
10
+ }
11
+
12
+ let (:platform_without_docker_image) {
13
+ plat = Vanagon::Platform::DSL.new('debian-6-i386')
14
+ plat.instance_eval("platform 'debian-6-i386' do |plat|
15
+ end")
16
+ plat._platform
17
+ }
18
+
19
+ describe '#initialize' do
20
+ it 'fails without docker installed' do
21
+ ENV['PATH'].split(File::PATH_SEPARATOR).each do |path_elem|
22
+ expect(FileTest).to receive(:executable?).with(File.join(path_elem, 'docker')).and_return(false)
23
+ end
24
+
25
+ expect { Vanagon::Engine::Docker.new(platform_with_docker_image) }.to raise_error(RuntimeError)
26
+ end
27
+ end
28
+
29
+ describe "#validate_platform" do
30
+ it 'raises an error if the platform is missing a required attribute' do
31
+ expect(Vanagon::Utilities).to receive(:find_program_on_path).with('docker').and_return('/usr/bin/docker')
32
+ expect { Vanagon::Engine::Docker.new(platform_without_docker_image).validate_platform }.to raise_error(Vanagon::Error)
33
+ end
34
+
35
+ it 'returns true if the platform has the required attributes' do
36
+ expect(Vanagon::Utilities).to receive(:find_program_on_path).with('docker').and_return('/usr/bin/docker')
37
+ expect(Vanagon::Engine::Docker.new(platform_with_docker_image).validate_platform).to be(true)
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,54 @@
1
+ require 'vanagon/engine/pooler'
2
+
3
+ describe 'Vanagon::Engine::Pooler' do
4
+ let (:platform) { double(Vanagon::Platform) }
5
+ let (:platform_with_vcloud_name) {
6
+ plat = Vanagon::Platform::DSL.new('debian-6-i386')
7
+ plat.instance_eval("platform 'debian-6-i386' do |plat|
8
+ plat.vcloud_name 'debian-6-i386'
9
+ end")
10
+ plat._platform
11
+ }
12
+
13
+ let (:platform_without_vcloud_name) {
14
+ plat = Vanagon::Platform::DSL.new('debian-6-i386')
15
+ plat.instance_eval("platform 'debian-6-i386' do |plat|
16
+ end")
17
+ plat._platform
18
+ }
19
+
20
+ describe "#load_token" do
21
+ after(:each) { ENV['VMPOOLER_TOKEN'] = nil }
22
+
23
+ let(:token_file) { double(File) }
24
+ let(:token_filename) { 'abcd' }
25
+
26
+ it 'prefers an env var to a file' do
27
+ ENV['VMPOOLER_TOKEN'] = 'abcd'
28
+ expect(File).to_not receive(:expand_path).with('~/.vanagon-token')
29
+ expect(Vanagon::Engine::Pooler.new(platform).token).to eq('abcd')
30
+ end
31
+
32
+ it 'falls back to a file if the env var is not set' do
33
+ expect(File).to receive(:expand_path).with('~/.vanagon-token').and_return(token_filename)
34
+ expect(File).to receive(:exist?).with(token_filename).and_return(true)
35
+ expect(File).to receive(:open).with(token_filename).and_return(token_file)
36
+ expect(token_file).to receive(:read).and_return('abcd')
37
+ expect(Vanagon::Engine::Pooler.new(platform).token).to eq('abcd')
38
+ end
39
+
40
+ it 'returns nil if there is no env var or file' do
41
+ expect(Vanagon::Engine::Pooler.new(platform).token).to be_nil
42
+ end
43
+ end
44
+
45
+ describe "#validate_platform" do
46
+ it 'raises an error if the platform is missing a required attribute' do
47
+ expect{ Vanagon::Engine::Pooler.new(platform_without_vcloud_name).validate_platform }.to raise_error(Vanagon::Error)
48
+ end
49
+
50
+ it 'returns true if the platform has the required attributes' do
51
+ expect(Vanagon::Engine::Pooler.new(platform_with_vcloud_name).validate_platform).to be(true)
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,60 @@
1
+ require 'vanagon/platform/deb'
2
+
3
+ describe "Vanagon::Platform::DEB" do
4
+ let(:platforms) do
5
+ [
6
+ {
7
+ :name => "ubuntu-10.04-i386",
8
+ :os_name => "ubuntu",
9
+ :os_version => "10.04",
10
+ :architecture => "i386",
11
+ :output_dir => "deb/lucid/",
12
+ :output_dir_with_target => "deb/lucid/thing",
13
+ :codename => "lucid",
14
+ },
15
+ {
16
+ :name => "debian-7-amd64",
17
+ :os_name => "debian",
18
+ :os_version => "7",
19
+ :architecture => "amd64",
20
+ :output_dir => "deb/wheezy/",
21
+ :output_dir_with_target => "deb/wheezy/thing",
22
+ :codename => "wheezy",
23
+ },
24
+ ]
25
+ end
26
+
27
+ describe "#output_dir" do
28
+ it "returns an output dir consistent with the packaging repo" do
29
+ platforms.each do |plat|
30
+
31
+ plat_block = %Q[
32
+ platform "#{plat[:name]}" do |plat|
33
+ plat.codename "#{plat[:codename]}"
34
+ end
35
+ ]
36
+
37
+ cur_plat = Vanagon::Platform::DSL.new(plat[:name])
38
+ cur_plat.instance_eval(plat_block)
39
+ expect(cur_plat._platform.output_dir).to eq(plat[:output_dir])
40
+ end
41
+ end
42
+
43
+ it "adds the target repo in the right place" do
44
+ platforms.each do |plat|
45
+
46
+ plat_block = %Q[
47
+ platform "#{plat[:name]}" do |plat|
48
+ plat.codename "#{plat[:codename]}"
49
+ end
50
+ ]
51
+
52
+ cur_plat = Vanagon::Platform::DSL.new(plat[:name])
53
+ cur_plat.instance_eval(plat_block)
54
+ expect(cur_plat._platform.output_dir('thing')).to eq(plat[:output_dir_with_target])
55
+ end
56
+ end
57
+ end
58
+ end
59
+
60
+
@@ -0,0 +1,128 @@
1
+ require 'vanagon/platform/dsl'
2
+
3
+ describe 'Vanagon::Platform::DSL' do
4
+ let (:deb_platform_block) { "platform 'debian-test-fixture' do |plat| end" }
5
+ let (:el_5_platform_block) { "platform 'el-5-fixture' do |plat| end" }
6
+ let (:el_6_platform_block) { "platform 'el-6-fixture' do |plat| end" }
7
+ let (:sles_platform_block) { "platform 'sles-test-fixture' do |plat| end" }
8
+ let (:nxos_5_platform_block) { "platform 'nxos-5-fixture' do |plat| end" }
9
+ let (:solaris_10_platform_block) { "platform 'solaris-10-fixture' do |plat| end" }
10
+ let (:solaris_11_platform_block) { "platform 'solaris-11-fixture' do |plat| end" }
11
+
12
+ let(:apt_definition) { "http://builds.delivery.puppetlabs.net/puppet-agent/0.2.1/repo_configs/deb/pl-puppet-agent-0.2.1-wheezy" }
13
+ let(:apt_definition_deb) { "http://builds.delivery.puppetlabs.net/puppet-agent/0.2.1/repo_configs/deb/pl-puppet-agent-0.2.1-wheezy.deb" }
14
+ let(:apt_definition_gpg) { "http://pl-build-tools.delivery.puppetlabs.net/debian/keyring.gpg" }
15
+ let(:el_definition) { "http://builds.delivery.puppetlabs.net/puppet-agent/0.2.1/repo_configs/rpm/pl-puppet-agent-0.2.1-el-7-x86_64" }
16
+ let(:el_definition_rpm) { "http://builds.delivery.puppetlabs.net/puppet-agent/0.2.1/repo_configs/rpm/pl-puppet-agent-0.2.1-release.rpm" }
17
+ let(:sles_definition) { "http://builds.delivery.puppetlabs.net/puppet-agent/0.2.2/repo_configs/rpm/pl-puppet-agent-0.2.2-sles-12-x86_64" }
18
+ let(:sles_definition_rpm) { "http://builds.delivery.puppetlabs.net/puppet-agent/0.2.1/repo_configs/rpm/pl-puppet-agent-0.2.1-release.rpm" }
19
+ let(:nxos_definition) { "http://builds.delivery.puppetlabs.net/puppet-agent/0.2.1/repo_configs/rpm/pl-puppet-agent-0.2.1-nxos-5-x86_64.repo" }
20
+
21
+ let(:hex_value) { "906264d248061b0edb1a576cc9c8f6c7" }
22
+
23
+ describe '#apt_repo' do
24
+ it "grabs the file and adds .list to it" do
25
+ plat = Vanagon::Platform::DSL.new('debian-test-fixture')
26
+ expect(SecureRandom).to receive(:hex).and_return(hex_value)
27
+ plat.instance_eval(deb_platform_block)
28
+ plat.apt_repo(apt_definition)
29
+ expect(plat._platform.provisioning).to include("curl -o '/etc/apt/sources.list.d/#{hex_value}-pl-puppet-agent-0.2.1-wheezy.list' '#{apt_definition}'")
30
+ end
31
+
32
+ it "installs a deb when given a deb" do
33
+ plat = Vanagon::Platform::DSL.new('debian-test-fixture')
34
+ plat.instance_eval(deb_platform_block)
35
+ plat.apt_repo(apt_definition_deb)
36
+ expect(plat._platform.provisioning).to include("curl -o local.deb '#{apt_definition_deb}' && dpkg -i local.deb; rm -f local.deb")
37
+ end
38
+
39
+ it "installs a gpg key if given one" do
40
+ plat = Vanagon::Platform::DSL.new('debian-test-fixture')
41
+ expect(SecureRandom).to receive(:hex).and_return(hex_value).twice
42
+ plat.instance_eval(deb_platform_block)
43
+ plat.apt_repo(apt_definition, apt_definition_gpg)
44
+ expect(plat._platform.provisioning).to include("curl -o '/etc/apt/trusted.gpg.d/#{hex_value}-keyring.gpg' '#{apt_definition_gpg}'")
45
+ end
46
+ end
47
+
48
+ describe '#yum_repo' do
49
+ it "grabs the file and adds .repo to it" do
50
+ plat = Vanagon::Platform::DSL.new('el-5-fixture')
51
+ expect(SecureRandom).to receive(:hex).and_return(hex_value)
52
+ plat.instance_eval(el_5_platform_block)
53
+ plat.yum_repo(el_definition)
54
+ expect(plat._platform.provisioning).to include("curl -o '/etc/yum.repos.d/#{hex_value}-pl-puppet-agent-0.2.1-el-7-x86_64.repo' '#{el_definition}'")
55
+ end
56
+
57
+ it "downloads the repo file to the correct yum location for nxos" do
58
+ plat = Vanagon::Platform::DSL.new('nxos-5-fixture')
59
+ expect(SecureRandom).to receive(:hex).and_return(hex_value)
60
+ plat.instance_eval(nxos_5_platform_block)
61
+ plat.yum_repo(nxos_definition)
62
+ expect(plat._platform.provisioning).to include("curl -o '/etc/yum/repos.d/#{hex_value}-pl-puppet-agent-0.2.1-nxos-5-x86_64.repo' '#{nxos_definition}'")
63
+ end
64
+
65
+ describe "installs a rpm when given a rpm" do
66
+ it 'uses yum on el 6 and higher' do
67
+ plat = Vanagon::Platform::DSL.new('el-6-fixture')
68
+ plat.instance_eval(el_6_platform_block)
69
+ plat.yum_repo(el_definition_rpm)
70
+ expect(plat._platform.provisioning).to include("yum localinstall -y '#{el_definition_rpm}'")
71
+ end
72
+
73
+ it 'uses rpm on el 5 and lower' do
74
+ plat = Vanagon::Platform::DSL.new('el-5-fixture')
75
+ plat.instance_eval(el_5_platform_block)
76
+ plat.yum_repo(el_definition_rpm)
77
+ expect(plat._platform.provisioning).to include("curl -o local.rpm '#{el_definition_rpm}'; rpm -Uvh local.rpm; rm -f local.rpm")
78
+ end
79
+ end
80
+ end
81
+
82
+ describe '#zypper_repo' do
83
+ it "grabs the file and adds .repo to it" do
84
+ plat = Vanagon::Platform::DSL.new('sles-test-fixture')
85
+ plat.instance_eval(sles_platform_block)
86
+ plat.zypper_repo(sles_definition)
87
+ expect(plat._platform.provisioning).to include("yes | zypper -n --no-gpg-checks ar -t YUM --repo '#{sles_definition}'")
88
+ end
89
+
90
+ it "installs a sles rpm when given a rpm" do
91
+ plat = Vanagon::Platform::DSL.new('sles-test-fixture')
92
+ plat.instance_eval(sles_platform_block)
93
+ plat.zypper_repo(sles_definition_rpm)
94
+ expect(plat._platform.provisioning).to include("curl -o local.rpm '#{sles_definition_rpm}'; rpm -Uvh local.rpm; rm -f local.rpm")
95
+ end
96
+ end
97
+
98
+ describe '#add_build_repository' do
99
+ it 'hands off to the platform specific method if defined' do
100
+ plat = Vanagon::Platform::DSL.new('solaris-test-fixture')
101
+ plat.instance_eval(solaris_11_platform_block)
102
+ plat.add_build_repository("http://solaris-repo.puppetlabs.com", "puppetlabs.com")
103
+ expect(plat._platform.provisioning).to include("pkg set-publisher -G '*' -g http://solaris-repo.puppetlabs.com puppetlabs.com")
104
+ end
105
+
106
+ it 'raises an error if the platform does not define "add_repository"' do
107
+ plat = Vanagon::Platform::DSL.new('solaris-test-fixture')
108
+ plat.instance_eval(solaris_10_platform_block)
109
+ expect {plat.add_build_repository("anything")}.to raise_error(Vanagon::Error, /Adding a build repository not defined/)
110
+ end
111
+ end
112
+
113
+ describe '#vmpooler_template' do
114
+ it 'sets the instance variable on platform' do
115
+ plat = Vanagon::Platform::DSL.new('solaris-test-fixture')
116
+ plat.instance_eval(solaris_10_platform_block)
117
+ plat.vmpooler_template 'solaris-10-x86_64'
118
+ expect(plat._platform.vmpooler_template).to eq('solaris-10-x86_64')
119
+ end
120
+
121
+ it 'is called by vcloud_name as a deprecation' do
122
+ plat = Vanagon::Platform::DSL.new('solaris-test-fixture')
123
+ plat.instance_eval(solaris_10_platform_block)
124
+ plat.vcloud_name 'solaris-11-x86_64'
125
+ expect(plat._platform.vmpooler_template).to eq('solaris-11-x86_64')
126
+ end
127
+ end
128
+ end