vanagon 0.18.1 → 0.21.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (84) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -2
  3. data/bin/build +3 -1
  4. data/bin/build_host_info +3 -1
  5. data/bin/build_requirements +3 -1
  6. data/bin/inspect +3 -1
  7. data/bin/render +3 -1
  8. data/bin/repo +3 -1
  9. data/bin/ship +3 -1
  10. data/bin/sign +3 -1
  11. data/lib/vanagon/cli.rb +4 -2
  12. data/lib/vanagon/cli/build.rb +2 -1
  13. data/lib/vanagon/cli/build_host_info.rb +3 -2
  14. data/lib/vanagon/cli/build_requirements.rb +4 -4
  15. data/lib/vanagon/cli/completion.rb +4 -3
  16. data/lib/vanagon/cli/inspect.rb +3 -2
  17. data/lib/vanagon/cli/list.rb +16 -6
  18. data/lib/vanagon/cli/render.rb +2 -1
  19. data/lib/vanagon/cli/ship.rb +4 -19
  20. data/lib/vanagon/cli/sign.rb +3 -2
  21. data/lib/vanagon/component.rb +13 -10
  22. data/lib/vanagon/component/dsl.rb +27 -20
  23. data/lib/vanagon/component/source.rb +2 -1
  24. data/lib/vanagon/component/source/git.rb +35 -10
  25. data/lib/vanagon/component/source/http.rb +3 -2
  26. data/lib/vanagon/component/source/local.rb +2 -1
  27. data/lib/vanagon/component/source/rewrite.rb +3 -2
  28. data/lib/vanagon/driver.rb +20 -23
  29. data/lib/vanagon/engine/always_be_scheduling.rb +12 -11
  30. data/lib/vanagon/engine/docker.rb +2 -1
  31. data/lib/vanagon/engine/ec2.rb +5 -4
  32. data/lib/vanagon/engine/hardware.rb +4 -3
  33. data/lib/vanagon/engine/pooler.rb +6 -5
  34. data/lib/vanagon/environment.rb +3 -2
  35. data/lib/vanagon/logger.rb +31 -0
  36. data/lib/vanagon/platform.rb +38 -5
  37. data/lib/vanagon/platform/defaults/debian-10-amd64.rb +11 -0
  38. data/lib/vanagon/platform/defaults/debian-8-amd64.rb +12 -0
  39. data/lib/vanagon/platform/defaults/debian-8-i386.rb +12 -0
  40. data/lib/vanagon/platform/defaults/debian-9-amd64.rb +12 -0
  41. data/lib/vanagon/platform/defaults/debian-9-i386.rb +12 -0
  42. data/lib/vanagon/platform/defaults/el-6-i386.rb +11 -0
  43. data/lib/vanagon/platform/defaults/el-6-x86_64.rb +11 -0
  44. data/lib/vanagon/platform/defaults/el-7-aarch64.rb +13 -0
  45. data/lib/vanagon/platform/defaults/el-7-x86_64.rb +11 -0
  46. data/lib/vanagon/platform/defaults/el-8-aarch64.rb +10 -0
  47. data/lib/vanagon/platform/defaults/el-8-x86_64.rb +10 -0
  48. data/lib/vanagon/platform/defaults/fedora-30-x86_64.rb +11 -0
  49. data/lib/vanagon/platform/defaults/fedora-31-x86_64.rb +11 -0
  50. data/lib/vanagon/platform/defaults/fedora-32-x86_64.rb +11 -0
  51. data/lib/vanagon/platform/defaults/osx-10.14-x86_64.rb +22 -0
  52. data/lib/vanagon/platform/defaults/osx-10.15-x86_64.rb +21 -0
  53. data/lib/vanagon/platform/defaults/redhatfips-7-x86_64.rb +11 -0
  54. data/lib/vanagon/platform/defaults/sles-12-x86_64.rb +11 -0
  55. data/lib/vanagon/platform/defaults/sles-15-x86_64.rb +10 -0
  56. data/lib/vanagon/platform/defaults/solaris-11-i386.rb +9 -0
  57. data/lib/vanagon/platform/defaults/solaris-11-sparc.rb +10 -0
  58. data/lib/vanagon/platform/defaults/ubuntu-16.04-amd64.rb +12 -0
  59. data/lib/vanagon/platform/defaults/ubuntu-16.04-i386.rb +12 -0
  60. data/lib/vanagon/platform/defaults/ubuntu-18.04-amd64.rb +12 -0
  61. data/lib/vanagon/platform/defaults/ubuntu-20.04-aarch64.rb +11 -0
  62. data/lib/vanagon/platform/defaults/ubuntu-20.04-amd64.rb +11 -0
  63. data/lib/vanagon/platform/dsl.rb +30 -6
  64. data/lib/vanagon/platform/windows.rb +3 -1
  65. data/lib/vanagon/project.rb +25 -15
  66. data/lib/vanagon/project/dsl.rb +6 -5
  67. data/lib/vanagon/utilities.rb +5 -4
  68. data/resources/deb/control.erb +1 -1
  69. data/resources/deb/postinst.erb +24 -13
  70. data/resources/deb/postrm.erb +9 -6
  71. data/resources/deb/prerm.erb +18 -8
  72. data/resources/osx/postinstall.erb +6 -2
  73. data/resources/rpm/project.spec.erb +12 -12
  74. data/resources/solaris/10/depend.erb +2 -2
  75. data/resources/solaris/10/postinstall.erb +11 -3
  76. data/resources/solaris/11/p5m.erb +2 -2
  77. data/spec/lib/vanagon/cli_spec.rb +57 -9
  78. data/spec/lib/vanagon/component/dsl_spec.rb +54 -10
  79. data/spec/lib/vanagon/component/source/git_spec.rb +4 -4
  80. data/spec/lib/vanagon/component_spec.rb +15 -2
  81. data/spec/lib/vanagon/engine/always_be_scheduling_spec.rb +4 -4
  82. data/spec/lib/vanagon/platform_spec.rb +80 -0
  83. data/spec/lib/vanagon/utilities_spec.rb +4 -1
  84. metadata +58 -31
@@ -14,8 +14,8 @@ describe "Vanagon::Component::Source::Git" do
14
14
 
15
15
  # before(:each) blocks are run before each example
16
16
  before :each do
17
- allow(Git)
18
- .to receive(:ls_remote)
17
+ allow(Vanagon::Component::Source::Git)
18
+ .to receive(:valid_remote?)
19
19
  .and_return(true)
20
20
 
21
21
  allow(File).to receive(:realpath).and_return(@workdir)
@@ -24,8 +24,8 @@ describe "Vanagon::Component::Source::Git" do
24
24
  describe "#initialize" do
25
25
  it "raises error on initialization with an invalid repo" do
26
26
  # Ensure initializing a repo fails without calling over the network
27
- allow(Git)
28
- .to receive(:ls_remote)
27
+ allow(Vanagon::Component::Source::Git)
28
+ .to receive(:valid_remote?)
29
29
  .and_return(false)
30
30
 
31
31
  expect { @klass.new(@url, ref: @ref_tag, workdir: @workdir) }
@@ -5,8 +5,9 @@ describe "Vanagon::Component" do
5
5
  describe "#get_environment" do
6
6
  subject { Vanagon::Component.new('env-test', {}, {}) }
7
7
 
8
- it "prints a deprecation warning to STDERR" do
9
- expect { subject.get_environment }.to output(/deprecated/).to_stderr
8
+ it "logs a deprecation warning with VanagonLogger.info" do
9
+ expect(VanagonLogger).to receive(:info).with(/deprecated/)
10
+ subject.get_environment
10
11
  end
11
12
 
12
13
  it "returns a makefile compatible environment" do
@@ -107,6 +108,18 @@ describe "Vanagon::Component" do
107
108
  expect(subject).to receive(:fetch_url)
108
109
  subject.get_source(@workdir)
109
110
  end
111
+
112
+ it 'retrieves from a canonical URI if VANAGON_USE_MIRRORS is set to "false"' do
113
+ allow(ENV).to receive(:[]).with('VANAGON_USE_MIRRORS').and_return('false')
114
+ allow(subject)
115
+ .to receive(:fetch_url)
116
+ .and_return(true)
117
+
118
+ # We expect #get_source to skip mirrors
119
+ expect(subject).not_to receive(:fetch_mirrors)
120
+ expect(subject).to receive(:fetch_url)
121
+ subject.get_source(@workdir)
122
+ end
110
123
  end
111
124
 
112
125
  describe "#get_sources" do
@@ -174,8 +174,8 @@ describe 'Vanagon::Engine::AlwaysBeScheduling' do
174
174
  hostname = 'fainter-whirlwind.puppet.com'
175
175
  stub_request(:post, "https://foobar/request").
176
176
  to_return({status: 404, body: "", headers: {}},{status: 200, body: '[{"hostname":"'+hostname+'","type":"aix-6.1-ppc","engine":"nspooler"}]', headers: {}})
177
- allow_any_instance_of(Object).to receive(:warn)
178
- expect_any_instance_of(Object).to receive(:warn).with("failed to request ABS with code 404")
177
+ allow_any_instance_of(VanagonLogger).to receive(:info)
178
+ expect_any_instance_of(VanagonLogger).to receive(:info).with("failed to request ABS with code 404")
179
179
  abs_service = Vanagon::Engine::AlwaysBeScheduling.new(platform, nil)
180
180
  pooler = abs_service.select_target_from("https://foobar")
181
181
  expect(pooler).to eq('')
@@ -186,8 +186,8 @@ describe 'Vanagon::Engine::AlwaysBeScheduling' do
186
186
  to_return({status: 202, body: "", headers: {}},
187
187
  {status: 503, body: "", headers: {}},
188
188
  {status: 200, body: '[{"hostname":"'+hostname+'","type":"aix-6.1-ppc","engine":"nspooler"}]', headers: {}})
189
- allow_any_instance_of(Object).to receive(:warn)
190
- expect_any_instance_of(Object).to receive(:warn).with(/Waiting 1 seconds to check if ABS request has been filled/)
189
+ allow_any_instance_of(VanagonLogger).to receive(:info)
190
+ expect_any_instance_of(VanagonLogger).to receive(:info).with(/Waiting 1 seconds to check if ABS request has been filled/)
191
191
  abs_service = Vanagon::Engine::AlwaysBeScheduling.new(platform, nil)
192
192
  abs_service.select_target_from("https://foobar")
193
193
  expect(abs_service.target).to eq(hostname)
@@ -1,6 +1,33 @@
1
1
  require 'vanagon/platform'
2
2
 
3
3
  describe "Vanagon::Platform" do
4
+ let(:deb_platform_just_servicedir) { "platform 'debian-test-fixture' do |plat|
5
+ plat.servicedir '/etc/init.d'
6
+ end
7
+ "}
8
+ let(:deb_platform_just_servicetype) { "platform 'debian-test-fixture' do |plat|
9
+ plat.servicetype 'sysv'
10
+ end
11
+ "}
12
+ let(:deb_platform_multi_servicetypes) { "platform 'debian-test-fixture' do |plat|
13
+ plat.servicetype 'sysv', servicedir: '/etc/init.d'
14
+ plat.servicetype 'systemd', servicedir: '/lib/systemd/system'
15
+ end
16
+ "}
17
+ let(:deb_platform_no_service) { "platform 'debian-test-fixture' do |plat|
18
+ end
19
+ "}
20
+ let(:deb_platform_servicetype) { "platform 'debian-test-fixture' do |plat|
21
+ plat.servicetype 'sysv'
22
+ plat.servicedir '/etc/init.d'
23
+ end
24
+ "}
25
+ let(:deb_platform_bad_servicedir_block) { "platform 'debian-test-fixture' do |plat|
26
+ plat.servicetype 'sysv', servicedir: '/etc/init.d'
27
+ plat.servicetype 'sysv', servicedir: '/etc/rc.d'
28
+ end
29
+ "}
30
+
4
31
  let(:platforms) do
5
32
  [
6
33
  {
@@ -172,4 +199,57 @@ describe "Vanagon::Platform" do
172
199
  end
173
200
  end
174
201
  end
202
+
203
+ describe "#get_service_type" do
204
+ it "returns plat.servicetype if that's the only thing set" do
205
+ plat = Vanagon::Platform::DSL.new('debian-8-x86_64')
206
+ plat.instance_eval(deb_platform_just_servicetype)
207
+ expect(plat._platform.get_service_types).to include('sysv')
208
+ end
209
+
210
+ it "returns from servicetypes if that's set" do
211
+ plat = Vanagon::Platform::DSL.new('debian-8-x86_64')
212
+ plat.instance_eval(deb_platform_servicetype)
213
+ expect(plat._platform.get_service_types).to include('sysv')
214
+ end
215
+
216
+ it "returns multiples if there's more than one" do
217
+ plat = Vanagon::Platform::DSL.new('debian-8-x86_64')
218
+ plat.instance_eval(deb_platform_multi_servicetypes)
219
+ expect(plat._platform.get_service_types).to include('sysv')
220
+ expect(plat._platform.get_service_types).to include('systemd')
221
+ end
222
+
223
+ it "returns an empty array if nothing is set" do
224
+ plat = Vanagon::Platform::DSL.new('debian-8-x86_64')
225
+ plat.instance_eval(deb_platform_no_service)
226
+ expect(plat._platform.get_service_types.size).to eq(0)
227
+ end
228
+ end
229
+
230
+ describe "#get_service_dir" do
231
+ it "returns plat.servicedir if that's the only thing set" do
232
+ plat = Vanagon::Platform::DSL.new('debian-8-x86_64')
233
+ plat.instance_eval(deb_platform_just_servicedir)
234
+ expect(plat._platform.get_service_dir).to eq('/etc/init.d')
235
+ end
236
+
237
+ it "returns servicedirs set via servicetype" do
238
+ plat = Vanagon::Platform::DSL.new('debian-8-x86_64')
239
+ plat.instance_eval(deb_platform_servicetype)
240
+ expect(plat._platform.get_service_dir).to eq('/etc/init.d')
241
+ end
242
+
243
+ it "returns the servicedir based on servicetype" do
244
+ plat = Vanagon::Platform::DSL.new('debian-8-x86_64')
245
+ plat.instance_eval(deb_platform_multi_servicetypes)
246
+ expect(plat._platform.get_service_dir('systemd')).to eq('/lib/systemd/system')
247
+ end
248
+
249
+ it "fails if there are >1 servicedir for a service type" do
250
+ plat = Vanagon::Platform::DSL.new('debian-8-x86_64')
251
+ plat.instance_eval(deb_platform_bad_servicedir_block)
252
+ expect { plat._platform.get_service_dir('sysv') }.to raise_error(Vanagon::Error)
253
+ end
254
+ end
175
255
  end
@@ -72,12 +72,15 @@ describe "Vanagon::Utilities" do
72
72
  describe '#local_command' do
73
73
  it 'runs commands in an unpolluted environment' do
74
74
  cmd = lambda { |arg| %(echo 'if [ "$#{arg}" = "" ]; then exit 0; else exit 1; fi' | /bin/sh) }
75
- vars = %w(BUNDLE_BIN_PATH BUNDLE_GEMFILE)
75
+ vars = %w[BUNDLE_BIN_PATH BUNDLE_GEMFILE]
76
76
  vars.each do |var|
77
77
  Vanagon::Utilities.local_command(cmd.call(var))
78
78
  expect($?.exitstatus).to eq(0)
79
79
  end
80
80
  end
81
+ it 'raises a RuntimeError when given a bad thing' do
82
+ expect { Vanagon::Utilities.local_command('__bogus__comand__') }.to raise_error(RuntimeError)
83
+ end
81
84
  end
82
85
 
83
86
  describe '#ssh_command' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vanagon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.18.1
4
+ version: 0.21.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Puppet Labs
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-12-09 00:00:00.000000000 Z
11
+ date: 2021-04-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: docopt
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 1.3.0
33
+ version: 1.8.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 1.3.0
40
+ version: 1.8.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: fustigit
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -148,9 +148,36 @@ files:
148
148
  - lib/vanagon/extensions/ostruct/json.rb
149
149
  - lib/vanagon/extensions/set/json.rb
150
150
  - lib/vanagon/extensions/string.rb
151
+ - lib/vanagon/logger.rb
151
152
  - lib/vanagon/patch.rb
152
153
  - lib/vanagon/platform.rb
153
154
  - lib/vanagon/platform/deb.rb
155
+ - lib/vanagon/platform/defaults/debian-10-amd64.rb
156
+ - lib/vanagon/platform/defaults/debian-8-amd64.rb
157
+ - lib/vanagon/platform/defaults/debian-8-i386.rb
158
+ - lib/vanagon/platform/defaults/debian-9-amd64.rb
159
+ - lib/vanagon/platform/defaults/debian-9-i386.rb
160
+ - lib/vanagon/platform/defaults/el-6-i386.rb
161
+ - lib/vanagon/platform/defaults/el-6-x86_64.rb
162
+ - lib/vanagon/platform/defaults/el-7-aarch64.rb
163
+ - lib/vanagon/platform/defaults/el-7-x86_64.rb
164
+ - lib/vanagon/platform/defaults/el-8-aarch64.rb
165
+ - lib/vanagon/platform/defaults/el-8-x86_64.rb
166
+ - lib/vanagon/platform/defaults/fedora-30-x86_64.rb
167
+ - lib/vanagon/platform/defaults/fedora-31-x86_64.rb
168
+ - lib/vanagon/platform/defaults/fedora-32-x86_64.rb
169
+ - lib/vanagon/platform/defaults/osx-10.14-x86_64.rb
170
+ - lib/vanagon/platform/defaults/osx-10.15-x86_64.rb
171
+ - lib/vanagon/platform/defaults/redhatfips-7-x86_64.rb
172
+ - lib/vanagon/platform/defaults/sles-12-x86_64.rb
173
+ - lib/vanagon/platform/defaults/sles-15-x86_64.rb
174
+ - lib/vanagon/platform/defaults/solaris-11-i386.rb
175
+ - lib/vanagon/platform/defaults/solaris-11-sparc.rb
176
+ - lib/vanagon/platform/defaults/ubuntu-16.04-amd64.rb
177
+ - lib/vanagon/platform/defaults/ubuntu-16.04-i386.rb
178
+ - lib/vanagon/platform/defaults/ubuntu-18.04-amd64.rb
179
+ - lib/vanagon/platform/defaults/ubuntu-20.04-aarch64.rb
180
+ - lib/vanagon/platform/defaults/ubuntu-20.04-amd64.rb
154
181
  - lib/vanagon/platform/dsl.rb
155
182
  - lib/vanagon/platform/osx.rb
156
183
  - lib/vanagon/platform/rpm.rb
@@ -294,39 +321,39 @@ summary: All of your packages will fit into this van with this one simple trick.
294
321
  test_files:
295
322
  - spec/lib/git/rev_list_spec.rb
296
323
  - spec/lib/makefile_spec.rb
297
- - spec/lib/vanagon/environment_spec.rb
298
- - spec/lib/vanagon/engine/pooler_spec.rb
299
- - spec/lib/vanagon/engine/docker_spec.rb
300
- - spec/lib/vanagon/engine/hardware_spec.rb
301
- - spec/lib/vanagon/engine/always_be_scheduling_spec.rb
302
- - spec/lib/vanagon/engine/base_spec.rb
303
- - spec/lib/vanagon/engine/local_spec.rb
304
- - spec/lib/vanagon/engine/ec2_spec.rb
305
- - spec/lib/vanagon/extensions/string_spec.rb
324
+ - spec/lib/vanagon/common/user_spec.rb
325
+ - spec/lib/vanagon/common/pathname_spec.rb
306
326
  - spec/lib/vanagon/extensions/set/json_spec.rb
327
+ - spec/lib/vanagon/extensions/string_spec.rb
307
328
  - spec/lib/vanagon/extensions/ostruct/json_spec.rb
308
- - spec/lib/vanagon/project_spec.rb
309
- - spec/lib/vanagon/common/pathname_spec.rb
310
- - spec/lib/vanagon/common/user_spec.rb
311
- - spec/lib/vanagon/component/source/git_spec.rb
312
- - spec/lib/vanagon/component/source/http_spec.rb
313
- - spec/lib/vanagon/component/source/local_spec.rb
314
- - spec/lib/vanagon/component/source/rewrite_spec.rb
315
- - spec/lib/vanagon/component/source_spec.rb
316
- - spec/lib/vanagon/component/rules_spec.rb
317
- - spec/lib/vanagon/component/dsl_spec.rb
318
329
  - spec/lib/vanagon/component_spec.rb
330
+ - spec/lib/vanagon/utilities/shell_utilities_spec.rb
331
+ - spec/lib/vanagon/platform_spec.rb
332
+ - spec/lib/vanagon/environment_spec.rb
319
333
  - spec/lib/vanagon/project/dsl_spec.rb
334
+ - spec/lib/vanagon/platform/osx_spec.rb
335
+ - spec/lib/vanagon/platform/dsl_spec.rb
336
+ - spec/lib/vanagon/platform/solaris_11_spec.rb
320
337
  - spec/lib/vanagon/platform/rpm/aix_spec.rb
338
+ - spec/lib/vanagon/platform/windows_spec.rb
321
339
  - spec/lib/vanagon/platform/deb_spec.rb
322
340
  - spec/lib/vanagon/platform/rpm_spec.rb
323
341
  - spec/lib/vanagon/platform/solaris_10_spec.rb
324
- - spec/lib/vanagon/platform/osx_spec.rb
325
- - spec/lib/vanagon/platform/windows_spec.rb
326
- - spec/lib/vanagon/platform/solaris_11_spec.rb
327
- - spec/lib/vanagon/platform/dsl_spec.rb
328
- - spec/lib/vanagon/cli_spec.rb
329
- - spec/lib/vanagon/platform_spec.rb
330
- - spec/lib/vanagon/utilities/shell_utilities_spec.rb
331
- - spec/lib/vanagon/utilities_spec.rb
342
+ - spec/lib/vanagon/component/rules_spec.rb
343
+ - spec/lib/vanagon/component/dsl_spec.rb
344
+ - spec/lib/vanagon/component/source/rewrite_spec.rb
345
+ - spec/lib/vanagon/component/source/git_spec.rb
346
+ - spec/lib/vanagon/component/source/local_spec.rb
347
+ - spec/lib/vanagon/component/source/http_spec.rb
348
+ - spec/lib/vanagon/component/source_spec.rb
332
349
  - spec/lib/vanagon/driver_spec.rb
350
+ - spec/lib/vanagon/project_spec.rb
351
+ - spec/lib/vanagon/utilities_spec.rb
352
+ - spec/lib/vanagon/cli_spec.rb
353
+ - spec/lib/vanagon/engine/ec2_spec.rb
354
+ - spec/lib/vanagon/engine/always_be_scheduling_spec.rb
355
+ - spec/lib/vanagon/engine/base_spec.rb
356
+ - spec/lib/vanagon/engine/docker_spec.rb
357
+ - spec/lib/vanagon/engine/local_spec.rb
358
+ - spec/lib/vanagon/engine/hardware_spec.rb
359
+ - spec/lib/vanagon/engine/pooler_spec.rb