Class: Pipeline::DockerMounter

Inherits:
BaseMounter show all
Defined in:
lib/pipeline/mounters/docker_mounter.rb

Instance Attribute Summary

Attributes inherited from BaseMounter

#description, #errors, #name, #trigger

Instance Method Summary collapse

Methods inherited from BaseMounter

#error

Constructor Details

#initialize(trigger, options) ⇒ DockerMounter

Pass in path to the root of the Rails application



8
9
10
11
# File 'lib/pipeline/mounters/docker_mounter.rb', line 8

def initialize trigger, options
	super(trigger)
  @options = options
end

Instance Method Details

#mount(target) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/pipeline/mounters/docker_mounter.rb', line 13

def mount target
  base = @options[:working_dir]
  target = target.slice(0, target.length - 7)
  working_target = base + "/docker/" + target + "/"
  Pipeline.notify "Cleaning directory: #{working_target}"
  if ! working_target.match(/\A.*\/line\/tmp\/.*/)
    Pipeline.notify "Bailing in case #{working_target} is malicious."      
  else
    result = `rm -rf #{working_target}`
    Pipeline.debug result
    result = `mkdir -p #{working_target}`
    Pipeline.debug result
    result = `docker export #{target} > #{working_target}#{target}.tar`
    Pipeline.debug result
    result = `tar -C #{working_target} -xf #{working_target}#{target}.tar`
    Pipeline.debug result
    result = `rm #{working_target}#{target}.tar`
    Pipeline.debug result
  end
  return working_target
end

#supports?(target) ⇒ Boolean

Returns:

  • (Boolean)


35
36
37
38
39
40
41
42
43
# File 'lib/pipeline/mounters/docker_mounter.rb', line 35

def supports? target
  last = target.slice(-7,target.length)
  Pipeline.debug "In Docker mounter, target: #{target} became: #{last} ... wondering if it matched .docker"
  if last === ".docker"
    return true
  else
    return false
  end
end