rummager 0.5.3 → 0.5.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 16d898882e16fff98a44d7fb1337cecea686894f
4
- data.tar.gz: e4ced1135eeaf4be86843c30e14cc43fcc9e67bb
3
+ metadata.gz: 863bf28b028cfdb7b01552a33f50f8646abf16be
4
+ data.tar.gz: 2a702ec6012cbcb865dab98a8e2d7fdc951146c4
5
5
  SHA512:
6
- metadata.gz: b0c82166972288d407cb0c1c0518758ef421245cb063500aa74be18373506227958267a99b3743e464a5af69ca1c8d3c77f30e9c1aa136285f7d34718fe89485
7
- data.tar.gz: 6b806770648f370378f580ca686109382720d55322efe84bcb92b2c8555a664389722738f04813435d2716481e0d7204baf65a1fda0949c3e0cdeae3040265d8
6
+ metadata.gz: 948dc6526647190bc651c888feb6fd11a2a7a3c531bd92c59d8f55e64a71caed209434e7f06b24083ee430b65398980da83053a0eda70ec08e685623710ae6d0
7
+ data.tar.gz: bc2d200c9b8395c99b6770e8961800ffa38ec5c430001bceb9c39a5f3a3663f3210a84c0990c81e4b2a47dffa9ab86525ec83c80175ea0f012922a267a71b62b
@@ -244,6 +244,7 @@ module Rummager
244
244
  class ClickContainer < Rake::TaskLib
245
245
  attr_accessor :container_name
246
246
  attr_accessor :image_name
247
+ attr_accessor :image_nobuild
247
248
  attr_accessor :repo_base
248
249
  attr_accessor :command
249
250
  attr_accessor :args_create
@@ -262,6 +263,7 @@ module Rummager
262
263
  def initialize(container_name,args={})
263
264
  @container_name = container_name
264
265
  @image_name = args.delete(:image_name) || container_name
266
+ @image_nobuild = args.delete(:image_nobuild)
265
267
  @repo_base = args.delete(:repo_base) || Rummager.repo_base
266
268
  @command = args.delete(:command)
267
269
  @args_create = args.delete(:args_create) || CNTNR_ARGS_CREATE
@@ -297,7 +299,13 @@ module Rummager
297
299
  realcreatetask.args_create = @args_create
298
300
  realcreatetask.command = @command
299
301
  realcreatetask.exposed_ports = @exposed_ports
300
- Rake::Task["containers:#{@container_name}:create"].enhance( [ :"images:#{@image_name}:build" ] )
302
+
303
+ if @image_nobuild == true
304
+ puts "skipping image build - assuming it exists" if Rake.verbose == true
305
+ else
306
+ Rake::Task["containers:#{@container_name}:create"].enhance( [ :"images:#{@image_name}:build" ] )
307
+ end
308
+
301
309
  if @dep_jobs
302
310
  @dep_jobs.each do |dj|
303
311
  Rake::Task["containers:#{@container_name}:create"].enhance( [ :"#{dj}" ] )
@@ -314,31 +322,43 @@ module Rummager
314
322
  starttask.publishall = @publishall
315
323
  starttask.exec_on_start = @exec_on_start
316
324
 
325
+ # ensure that containers from which volumes will be attached
326
+ # are started before this container is started, otherwise
327
+ # docker volumes_from will fail
317
328
  Rake::Task["containers:#{@container_name}:start"].enhance( [ :"containers:#{@container_name}:create" ] )
318
329
  if @volumes_from
319
330
  @volumes_from.each do |vf|
320
331
  Rake::Task["containers:#{@container_name}:create"].enhance([:"containers:#{vf}:start" ])
321
332
  end
322
333
  end
334
+
335
+ # stop task
336
+ stoptask = Rummager::ContainerStopTask.define_task :stop
337
+ stoptask.container_name = @container_name
338
+ Rake::Task[:"containers:stop"].enhance( [ :"containers:#{@container_name}:stop" ] )
339
+
340
+ # enter task
323
341
  if @allow_enter
324
342
  # build and jump into an environment
325
343
  entertask = Rummager::ContainerEnterTask.define_task :enter
326
344
  entertask.container_name = @container_name
345
+ Rake::Task["containers:#{@container_name}:enter"].enhance([ :"containers:#{@container_name}:start" ])
346
+ # wire in any jobs marked as required to enter
347
+ # jobs must be defined on this container
327
348
  @enter_dep_jobs.each do |edj|
328
349
  Rake::Task["containers:#{@container_name}:enter"].enhance([ :"containers:#{@container_name}:jobs:#{edj}" ])
329
350
  end
330
- Rake::Task["containers:#{@container_name}:enter"].enhance([ :"containers:#{@container_name}:start" ])
331
351
  end # allow_enter
332
-
333
- # stop task
334
- stoptask = Rummager::ContainerStopTask.define_task :stop
335
- stoptask.container_name = @container_name
336
- Rake::Task[:"containers:stop"].enhance( [ :"containers:#{@container_name}:stop" ] )
337
352
 
338
353
  # Remove task
339
354
  rmtask = Rummager::ContainerRMTask.define_task :rm
340
355
  rmtask.container_name = @container_name
341
- Rake::Task["images:#{@image_name}:rmi"].enhance( [ "containers:#{@container_name}:rm" ] )
356
+ if @image_nobuild == true
357
+ puts "skipping #{@image_name}:rmi dependency on #{@container_name}:rm" if Rake.verbose == true
358
+ else
359
+ Rake::Task["images:#{@image_name}:rmi"].enhance( [ "containers:#{@container_name}:rm" ] )
360
+ end
361
+
342
362
  Rake::Task["containers:#{@container_name}:rm"].enhance( [ :"containers:#{@container_name}:stop" ] )
343
363
 
344
364
  if @noclean == true
@@ -360,20 +380,33 @@ module Rummager
360
380
  class ContainerExecTask < Rummager::ContainerTaskBase
361
381
  attr_accessor :exec_list
362
382
  attr_accessor :ident_hash
383
+ attr_accessor :needed_test
363
384
 
364
385
  def ident_filename
365
386
  "/.once-#{@ident_hash}"
366
387
  end
367
388
 
368
389
  def needed?
369
- if ! @ident_hash.nil?
370
- puts "checking for #{ident_filename} in container"
390
+ if ! @needed_test.nil?
391
+ puts "running needed_test '#{needed_test}' in '#{@container_name}'" if Rake.verbose == true
392
+ begin
393
+ return_arry = docker_obj.exec(@needed_test)
394
+ puts "test '#{needed_test}' => '#{return_arry[0]}':#{return_arry[2]}" if Rake.verbose == true
395
+ return (0 == return_arry[2])
396
+ rescue => ex
397
+ puts "test '#{needed_test}' failed in '#{@container_name}':#{ex.message}"
398
+ return false
399
+ end
400
+ elsif ! @ident_hash.nil?
401
+ puts "checking for #{ident_filename} in container" if Rake.verbose == true
371
402
  begin
372
403
  docker_obj.copy("#{ident_filename}")
373
404
  return false
374
405
  rescue
375
- puts "#{ident_filename} not found"
406
+ puts "#{ident_filename} not found" if Rake.verbose == true
376
407
  end
408
+ else
409
+ puts "neither @needed_test nor @ident_hash defined for #{@task_name}" if Rake.verbose == true
377
410
  end
378
411
  # no ident hash, or not found
379
412
  true
@@ -418,6 +451,7 @@ module Rummager
418
451
  attr_accessor :job_name
419
452
  attr_accessor :container_name
420
453
  attr_accessor :exec_list
454
+ attr_accessor :needed_test
421
455
  attr_accessor :ident_hash
422
456
  attr_accessor :dep_jobs
423
457
 
@@ -434,6 +468,7 @@ module Rummager
434
468
  end
435
469
  @exec_list = args.delete(:exec_list)
436
470
  @dep_jobs = args.delete(:dep_jobs)
471
+ @needed_test = args.delete(:needed_test)
437
472
  if !args.empty?
438
473
  raise ArgumentError, "ClickExec'#{@job_name}' defenition has unused/invalid key-values:#{args}"
439
474
  end
@@ -452,6 +487,7 @@ module Rummager
452
487
  exectask.container_name = @container_name
453
488
  exectask.exec_list = @exec_list
454
489
  exectask.ident_hash = @ident_hash
490
+ exectask.needed_test = @needed_test
455
491
  Rake::Task[:"containers:#{@container_name}:jobs:#{job_name}"].enhance( [:"containers:#{@container_name}:start"] )
456
492
  if @dep_jobs
457
493
  @dep_jobs.each do |dj|
@@ -133,7 +133,7 @@ class Rummager::ImageRMITask < Rummager::ImageTaskBase
133
133
  def initialize(task_name, app)
134
134
  super(task_name,app)
135
135
  @actions << Proc.new {
136
- puts "removing image '#{t.repo}'" if Rake.verbose == true
136
+ puts "removing image '#{@repo}'" if Rake.verbose == true
137
137
  Docker::Image.all(:all => true).each do |img|
138
138
  if img.info['RepoTags'].any? { |s| s.include?(@repo) }
139
139
  begin
@@ -1,39 +1,52 @@
1
1
  module Rummager
2
2
 
3
+ def Rummager.cmd_shexec(cmdstring)
4
+ {
5
+ :cmd=> [ "/bin/sh","-c", cmdstring ],
6
+ }
7
+ end # cmd_bashexec
8
+
9
+ def Rummager.cmd_bashexec(cmdstring)
10
+ {
11
+ :cmd=> [ "/bin/bash","-c", cmdstring ],
12
+ }
13
+ end # cmd_bashexec
14
+
3
15
  def Rummager.cmd_gitmirror(filepath,giturl)
4
16
  {
5
17
  :cmd=> [ "/bin/bash","-c",
6
- "if [[ -d #{filepath} ]]; then\n" \
7
- " /usr/bin/git --git-dir=#{filepath} fetch --all\n" \
8
- "else\n" \
9
- " /usr/bin/git clone --mirror #{giturl} #{filepath}\n" \
10
- "fi\n"],
18
+ "if [[ -d #{filepath} ]]; then\n" \
19
+ " /usr/bin/git --git-dir=#{filepath} fetch --all\n" \
20
+ "else\n" \
21
+ " /usr/bin/git clone --mirror #{giturl} #{filepath}\n" \
22
+ "fi\n"
23
+ ],
11
24
  }
12
- end # mirror_or_update
25
+ end # cmd_gitmirror
13
26
 
14
27
  def Rummager.cmd_gitupdate(filepath)
15
28
  {
16
29
  :cmd=> [ "/bin/bash","-c",
17
- "/usr/bin/git --git-dir=#{filepath} fetch --all",
30
+ "/usr/bin/git --git-dir=#{filepath} fetch --all",
18
31
  ],
19
32
  }
20
33
  end # cmd_gitupdate
21
34
 
22
35
  def Rummager.cmd_gitclone(branch,srcpath,clonepath)
23
36
  {
24
- :cmd => ["/bin/sh","-c",
25
- "/usr/bin/git clone --branch #{branch} #{srcpath} #{clonepath}"
37
+ :cmd => ["/bin/bash","-c",
38
+ "/usr/bin/git clone --branch #{branch} #{srcpath} #{clonepath}"
26
39
  ],
27
40
  }
28
41
  end # cmd_gitclone
29
42
 
30
43
  def Rummager.cmd_gitcheckout(commithash,srcpath,clonepath)
31
44
  {
32
- :cmd => ["/bin/sh","-c",
33
- "/usr/bin/git clone --no-checkout #{srcpath} #{clonepath}\n" \
34
- "/usr/bin/git --work-tree #{clonepath} --git-dir #{clonepath}/.git checkout #{commithash}\n"
45
+ :cmd => ["/bin/bash","-c",
46
+ "/usr/bin/git clone --no-checkout #{srcpath} #{clonepath} &&" \
47
+ "/usr/bin/git --work-tree #{clonepath} --git-dir #{clonepath}/.git checkout #{commithash}\n"
35
48
  ],
36
49
  }
37
- end # cmd_gitclone
50
+ end # cmd_gitcheckout
38
51
 
39
52
  end # Rummager
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rummager
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.3
4
+ version: 0.5.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - y3ddet, ted@xassembly.com
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-24 00:00:00.000000000 Z
11
+ date: 2015-05-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake