Class: RakeDocker::Container::Provisioner

Inherits:
Object
  • Object
show all
Includes:
Utilities
Defined in:
lib/rake_docker/container.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Utilities

#enhance_with_name, #find_container

Constructor Details

#initialize(name, image, opts = {}) ⇒ Provisioner

Returns a new instance of Provisioner.



146
147
148
149
150
151
152
153
# File 'lib/rake_docker/container.rb', line 146

def initialize(name, image, opts = {})
  @name = name
  @image = image
  @environment = opts[:environment] || {}
  @ports = opts[:ports] || []
  @ready = opts[:ready?]
  @reporter = opts[:reporter] || NullReporter.new
end

Instance Attribute Details

#environmentObject (readonly)

Returns the value of attribute environment.



144
145
146
# File 'lib/rake_docker/container.rb', line 144

def environment
  @environment
end

#imageObject (readonly)

Returns the value of attribute image.



144
145
146
# File 'lib/rake_docker/container.rb', line 144

def image
  @image
end

#nameObject (readonly)

Returns the value of attribute name.



144
145
146
# File 'lib/rake_docker/container.rb', line 144

def name
  @name
end

#portsObject (readonly)

Returns the value of attribute ports.



144
145
146
# File 'lib/rake_docker/container.rb', line 144

def ports
  @ports
end

#readyObject (readonly)

Returns the value of attribute ready.



144
145
146
# File 'lib/rake_docker/container.rb', line 144

def ready
  @ready
end

#reporterObject (readonly)

Returns the value of attribute reporter.



144
145
146
# File 'lib/rake_docker/container.rb', line 144

def reporter
  @reporter
end

Instance Method Details

#executeObject



155
156
157
158
159
160
161
162
163
164
165
166
167
# File 'lib/rake_docker/container.rb', line 155

def execute
  reporter.checking_if_container_exists(name)
  container = find_container(name)
  if container
    reporter.container_exists(container)
    ensure_container_running(container)
  else
    reporter.container_does_not_exist(name)
    ensure_image_available(image)
    create_and_start_container(name, image, ports, environment)
  end
  reporter.done
end